cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r790881 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/ systests/src/tes...
Date Fri, 03 Jul 2009 12:03:25 GMT
Author: sergeyb
Date: Fri Jul  3 12:03:25 2009
New Revision: 790881

URL: http://svn.apache.org/viewvc?rev=790881&view=rev
Log:
Merged revisions 790868 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r790868 | sergeyb | 2009-07-03 12:43:37 +0100 (Fri, 03 Jul 2009) | 1 line
  
  JAX-RS : adding WebClient.path() which can deal with templates, updating AbstractClient.readBody
to return null only if Content-Length is 0 or absent, fixing HTTPHeadersImpl NPE issue
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
    cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul  3 12:03:25 2009
@@ -1 +1 @@
-/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644
+/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=790881&r1=790880&r2=790881&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
Fri Jul  3 12:03:25 2009
@@ -73,7 +73,7 @@
  * Common proxy and http-centric client implementation
  *
  */
-public class AbstractClient implements Client, InvocationHandlerAware {
+public class AbstractClient implements Client {
     private static final Logger LOG = LogUtils.getL7dLogger(AbstractClient.class);
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(AbstractClient.class);
 
@@ -369,13 +369,20 @@
     }
     
     @SuppressWarnings("unchecked")
-    protected Object readBody(Response r, HttpURLConnection conn, Message inMessage, 
-                              Class<?> cls, Type type, Annotation[] anns) {
+    protected Object readBody(Response r, HttpURLConnection conn, Message inMessage, Class<?>
cls, 
+                              Type type, Annotation[] anns) {
 
+        InputStream inputStream = (InputStream)r.getEntity();
+        if (inputStream == null) {
+            return cls == Response.class ? cls : null;
+        }
         try {
             int status = conn.getResponseCode();
             if (status < 200 || status == 204 || status > 300) {
-                return null;
+                Object length = r.getMetadata().getFirst(HttpHeaders.CONTENT_LENGTH);
+                if (length == null || Integer.parseInt(length.toString()) == 0) {
+                    return cls == Response.class ? cls : null;
+                }
             }
         } catch (IOException ex) {
             // won't happen at this stage
@@ -392,8 +399,7 @@
         if (mbr != null) {
             try {
                 return mbr.readFrom(cls, type, anns, contentType, 
-                       new MetadataMap<String, Object>(r.getMetadata(), true, true),

-                       (InputStream)r.getEntity());
+                       new MetadataMap<String, Object>(r.getMetadata(), true, true),
inputStream);
             } catch (Exception ex) {
                 throw new WebApplicationException();
             }
@@ -569,9 +575,7 @@
         
     }
 
-    public Object getInvocationHandler() {
-        return this;
-    }
+    
 
 
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=790881&r1=790880&r2=790881&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
Fri Jul  3 12:03:25 2009
@@ -62,7 +62,7 @@
  * Proxy-based client implementation
  *
  */
-public class ClientProxyImpl extends AbstractClient implements InvocationHandler {
+public class ClientProxyImpl extends AbstractClient implements InvocationHandlerAware, InvocationHandler
{
 
     private static final Logger LOG = LogUtils.getL7dLogger(ClientProxyImpl.class);
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ClientProxyImpl.class);
@@ -407,6 +407,10 @@
                         method.getGenericReturnType(), method.getDeclaredAnnotations());
     }
 
+    public Object getInvocationHandler() {
+        return this;
+    }
+    
     protected static void reportInvalidResourceMethod(Method m, String name) {
         org.apache.cxf.common.i18n.Message errorMsg = 
             new org.apache.cxf.common.i18n.Message(name, 

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=790881&r1=790880&r2=790881&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
Fri Jul  3 12:03:25 2009
@@ -36,6 +36,7 @@
 import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.UriBuilder;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
@@ -304,6 +305,17 @@
     }
     
     /**
+     * Updates the current URI path with path segment which may contain template variables
+     * @param path new relative path segment
+     * @param values template variable values
+     * @return updated WebClient
+     */
+    public WebClient path(String path, Object... values) {
+        URI u = UriBuilder.fromUri(URI.create("http://tempuri")).path(path).buildFromEncoded(values);
+        return path(u.getRawPath());
+    }
+    
+    /**
      * Updates the current URI query parameters
      * @param name query name
      * @param values query values

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java?rev=790881&r1=790880&r2=790881&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
Fri Jul  3 12:03:25 2009
@@ -123,7 +123,7 @@
 
     private List<String> getListValues(String headerName) {
         List<String> values = headers.get(headerName);
-        if (values == null || values.isEmpty()) {
+        if (values == null || values.isEmpty() || values.get(0) == null) {
             return Collections.emptyList();
         }
         if (HttpUtils.isDateRelatedHeader(headerName)) {

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java?rev=790881&r1=790880&r2=790881&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
Fri Jul  3 12:03:25 2009
@@ -133,4 +133,14 @@
         assertEquals(URI.create("http://foo"), wc.getCurrentURI());
     }
     
+    @Test
+    public void testPathWithTemplates() {
+        WebClient wc = WebClient.create(URI.create("http://foo"));
+        assertEquals(URI.create("http://foo"), wc.getBaseURI());
+        assertEquals(URI.create("http://foo"), wc.getCurrentURI());
+        
+        wc.path("{bar}/{foo}", 1, 2);
+        assertEquals(URI.create("http://foo"), wc.getBaseURI());
+        assertEquals(URI.create("http://foo/1/2"), wc.getCurrentURI());
+    }
 }

Modified: cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=790881&r1=790880&r2=790881&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
Fri Jul  3 12:03:25 2009
@@ -476,7 +476,7 @@
     }
     
     @Ignore
-    private class TestFeature extends AbstractFeature {
+    public class TestFeature extends AbstractFeature {
         private TestInterceptor testInterceptor;
 
         @Override
@@ -491,7 +491,7 @@
     }
  
     @Ignore
-    private class TestInterceptor extends AbstractPhaseInterceptor<Message> {
+    public class TestInterceptor extends AbstractPhaseInterceptor<Message> {
         private boolean handleMessageCalled;
         public TestInterceptor() {
             this(Phase.PRE_STREAM);



Mime
View raw message