Changeset 801
- Timestamp:
- 06/29/07 11:21:33 (2 years ago)
- Files:
-
- org.jalcedo.client/trunk/org.jalcedo.client.rest/build.properties (modified) (2 diffs)
- org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/Connection.java (modified) (2 diffs)
- org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/HttpClientConnection.java (modified) (6 diffs)
- org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/Representation.java (moved) (moved from org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/RequestEntity.java) (4 diffs)
- org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/StringRepresentation.java (moved) (moved from org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/StringRequestEntity.java) (2 diffs)
- org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/WWWFormUrlEncodedRepresentation.java (moved) (moved from org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/FormRequestEntity.java) (4 diffs)
- org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/data (added)
- org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/data/Message.java (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
org.jalcedo.client/trunk/org.jalcedo.client.rest/build.properties
r778 r801 1 source.. = src/,\ 2 json-src/ 1 source.. = src/ 3 2 output.. = bin/ 4 3 bin.includes = META-INF/,\ … … 9 8 META-INF/,\ 10 9 build.properties,\ 11 json-src/,\12 lib/,\13 lib-http/,\14 lib-json/,\15 10 src/ org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/Connection.java
r778 r801 43 43 * @return 44 44 */ 45 Response put(String url, Map<String, String> queryParams, Re questEntitybody) throws ConnectionException;45 Response put(String url, Map<String, String> queryParams, Representation body) throws ConnectionException; 46 46 47 47 /** … … 52 52 * @return 53 53 */ 54 Response post(String url, Map<String, String> queryParams, Re questEntitybody) throws ConnectionException;54 Response post(String url, Map<String, String> queryParams, Representation body) throws ConnectionException; 55 55 } org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/HttpClientConnection.java
r778 r801 182 182 */ 183 183 public Response post(String url, Map<String, String> queryParams, 184 Re questEntitybody) throws ConnectionException {184 Representation body) throws ConnectionException { 185 185 try { 186 186 PostMethod method = new PostMethod(url); … … 199 199 */ 200 200 public Response put(String url, Map<String, String> queryParams, 201 Re questEntitybody) throws ConnectionException {201 Representation body) throws ConnectionException { 202 202 try { 203 203 PutMethod method = new PutMethod(url); … … 218 218 * @throws IOException 219 219 */ 220 private Response doEntityEnclosingMethod(Re questEntitybody,220 private Response doEntityEnclosingMethod(Representation body, 221 221 Map<String, String> queryParams, EntityEnclosingMethod method) 222 222 throws HttpException, IOException { … … 305 305 private class RequestEntityWrapper implements 306 306 org.apache.commons.httpclient.methods.RequestEntity { 307 private final Re questEntityrequestEntity;308 309 public RequestEntityWrapper(Re questEntityrequestEntity) {307 private final Representation requestEntity; 308 309 public RequestEntityWrapper(Representation requestEntity) { 310 310 this.requestEntity = requestEntity; 311 311 } … … 316 316 317 317 public String getContentType() { 318 return requestEntity.get ContentType();318 return requestEntity.getMediaType(); 319 319 } 320 320 … … 324 324 325 325 public void writeRequest(OutputStream out) throws IOException { 326 requestEntity.write Request(out);326 requestEntity.write(out); 327 327 } 328 328 } org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/Representation.java
r689 r801 12 12 13 13 import java.io.IOException; 14 import java.io.InputStream; 14 15 import java.io.OutputStream; 15 16 … … 19 20 * 20 21 */ 21 public interface Re questEntity{22 public interface Representation { 22 23 /** 23 24 * … … 29 30 * @return 30 31 */ 31 String get ContentType();32 String getMediaType(); 32 33 /** 33 34 * … … 39 40 * @param out 40 41 */ 41 void writeRequest(OutputStream out) throws IOException; 42 void write(OutputStream out) throws IOException; 43 44 /** 45 * 46 * @return 47 * @throws IOException 48 */ 49 InputStream read() throws IOException; 42 50 } org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/StringRepresentation.java
r689 r801 11 11 package org.jalcedo.client.rest.connect; 12 12 13 import java.io.IOException; 14 import java.io.InputStream; 15 import java.io.OutputStream; 13 16 import java.io.UnsupportedEncodingException; 14 17 … … 18 21 * 19 22 */ 20 public class StringRe questEntityextends org.apache.commons.httpclient.methods.StringRequestEntity21 implements Re questEntity{23 public class StringRepresentation extends org.apache.commons.httpclient.methods.StringRequestEntity 24 implements Representation { 22 25 23 public StringRe questEntity(String content, String contentType,26 public StringRepresentation(String content, String contentType, 24 27 String charset) throws UnsupportedEncodingException { 25 28 super(content, contentType, charset); 26 29 } 30 31 public String getMediaType() { 32 return this.getContentType(); 33 } 34 public void write(OutputStream out) throws IOException { 35 this.writeRequest(out); 36 } 37 38 public InputStream read() throws IOException { 39 // FIXME 40 throw new UnsupportedOperationException(); 41 } 27 42 } org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/WWWFormUrlEncodedRepresentation.java
r730 r801 12 12 13 13 import java.io.IOException; 14 import java.io.InputStream; 14 15 import java.io.OutputStream; 15 16 import java.io.UnsupportedEncodingException; … … 21 22 * 22 23 */ 23 public class FormRequestEntity implements RequestEntity{24 public class WWWFormUrlEncodedRepresentation implements Representation { 24 25 25 26 private StringBuilder data = new StringBuilder(); 26 27 private String charset; 27 28 28 private StringRe questEntitywrapper = null;29 private StringRepresentation wrapper = null; 29 30 30 public FormRequestEntity() {31 public WWWFormUrlEncodedRepresentation() { 31 32 this("utf-8"); 32 33 } 33 34 34 public FormRequestEntity(String charset) {35 public WWWFormUrlEncodedRepresentation(String charset) { 35 36 this.charset = charset; 36 37 } … … 46 47 } 47 48 48 protected Re questEntitygetWrapper() {49 protected Representation getWrapper() { 49 50 if (this.wrapper == null) { 50 51 try { 51 this.wrapper = new StringRe questEntity(this.data.toString(), "application/x-www-form-urlencoded", this.charset);52 this.wrapper = new StringRepresentation(this.data.toString(), "application/x-www-form-urlencoded", this.charset); 52 53 } catch (UnsupportedEncodingException e) { 53 54 throw new IllegalStateException(e); … … 58 59 59 60 public long getContentLength() { 60 Re questEntitywrapper = this.getWrapper();61 Representation wrapper = this.getWrapper(); 61 62 return wrapper.getContentLength(); 62 63 } 63 64 64 public String get ContentType() {65 Re questEntitywrapper = this.getWrapper();66 return wrapper.get ContentType();65 public String getMediaType() { 66 Representation wrapper = this.getWrapper(); 67 return wrapper.getMediaType(); 67 68 } 68 69 69 70 public boolean isRepeatable() { 70 Re questEntitywrapper = this.getWrapper();71 Representation wrapper = this.getWrapper(); 71 72 return wrapper.isRepeatable(); 72 73 } 73 74 74 public void write Request(OutputStream out) throws IOException {75 Re questEntitywrapper = this.getWrapper();76 wrapper.write Request(out);75 public void write(OutputStream out) throws IOException { 76 Representation wrapper = this.getWrapper(); 77 wrapper.write(out); 77 78 } 78 79 80 public InputStream read() throws IOException { 81 // TODO Auto-generated method stub 82 return null; 83 } 79 84 }
