Changeset 729

Show
Ignore:
Timestamp:
06/20/07 15:51:52 (2 years ago)
Author:
yuanying
Message:

API is changed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/Connection.java

    r656 r729  
    2626     * @return 
    2727     */ 
    28     String get(String url, Map<String, String> queryParams) throws ConnectionException; 
     28    Response get(String url, Map<String, String> queryParams) throws ConnectionException; 
    2929     
    3030    /** 
     
    3434     * @return 
    3535     */ 
    36     String delete(String url, Map<String, String> queryParams) throws ConnectionException; 
     36    Response delete(String url, Map<String, String> queryParams) throws ConnectionException; 
    3737     
    3838    /** 
     
    4343     * @return 
    4444     */ 
    45     String put(String url, RequestEntity body, Map<String, String> queryParams) throws ConnectionException; 
     45    Response put(String url, RequestEntity body, Map<String, String> queryParams) throws ConnectionException; 
    4646     
    4747    /** 
     
    5252     * @return 
    5353     */ 
    54     String post(String url, RequestEntity body, Map<String, String> queryParams) throws ConnectionException; 
     54    Response post(String url, RequestEntity body, Map<String, String> queryParams) throws ConnectionException; 
    5555} 
  • org.jalcedo.client/trunk/org.jalcedo.client.rest/src/org/jalcedo/client/rest/connect/HttpClientConnection.java

    r717 r729  
    1212 
    1313import java.io.IOException; 
     14import java.io.InputStream; 
    1415import java.io.OutputStream; 
    1516import java.util.ArrayList; 
     
    7273     *      java.util.Map) 
    7374     */ 
    74     public String delete(String url, Map<String, String> queryParams) 
     75    public Response delete(String url, Map<String, String> queryParams) 
    7576            throws ConnectionException { 
    7677        try { 
     
    8990     *      java.util.Map) 
    9091     */ 
    91     public String get(String url, Map<String, String> queryParams) 
     92    public Response get(String url, Map<String, String> queryParams) 
    9293            throws ConnectionException { 
    9394        try { 
     
    111112     * @throws IOException 
    112113     */ 
    113     private String doMethod(Map<String, String> queryParams, HttpMethod method) 
     114    private Response doMethod(Map<String, String> queryParams, HttpMethod method) 
    114115            throws HttpException, IOException { 
    115116        this.setQueryString(method, queryParams); 
     
    121122            return this.get(redirectUri.toString(), new HashMap<String, String>()); 
    122123        } 
    123         return method.getResponseBodyAsString(); 
     124        return new HttpResponse(method); 
    124125    } 
    125126     
     
    170171     *      org.jalcedo.client.rest.connect.RequestEntity, java.util.Map) 
    171172     */ 
    172     public String post(String url, RequestEntity body, 
     173    public Response post(String url, RequestEntity body, 
    173174            Map<String, String> queryParams) throws ConnectionException { 
    174175        try { 
     
    187188     *      org.jalcedo.client.rest.connect.RequestEntity, java.util.Map) 
    188189     */ 
    189     public String put(String url, RequestEntity body, 
     190    public Response put(String url, RequestEntity body, 
    190191            Map<String, String> queryParams) throws ConnectionException { 
    191192        try { 
     
    207208     * @throws IOException 
    208209     */ 
    209     private String doEntityEnclosingMethod(RequestEntity body, 
     210    private Response doEntityEnclosingMethod(RequestEntity body, 
    210211            Map<String, String> queryParams, EntityEnclosingMethod method) 
    211212            throws HttpException, IOException { 
     
    313314        } 
    314315    } 
     316     
     317    private class HttpResponse implements Response { 
     318         
     319        final private HttpMethod method; 
     320         
     321        public HttpResponse(HttpMethod method) { 
     322            this.method = method; 
     323        } 
     324 
     325        public String getContentType() { 
     326            return this.method.getResponseHeader("content-type").getValue(); 
     327        } 
     328 
     329        public InputStream getStream() throws IOException { 
     330            return this.method.getResponseBodyAsStream(); 
     331        } 
     332 
     333        public String getText() throws IOException { 
     334            return this.method.getResponseBodyAsString(); 
     335        } 
     336         
     337    } 
    315338}