cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r889365 - 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/ext/atom/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/ja...
Date Thu, 10 Dec 2009 18:51:26 GMT
Author: sergeyb
Date: Thu Dec 10 18:51:25 2009
New Revision: 889365

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

........
  r887317 | sergeyb | 2009-12-04 18:46:07 +0000 (Fri, 04 Dec 2009) | 1 line
  
  Adding AtomPojoProvider plus few minor fixes
........

Added:
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/
      - copied from r887317, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AbstractAtomElementBuilder.java
      - copied unchanged from r887317, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AbstractAtomElementBuilder.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AbstractEntryBuilder.java
      - copied unchanged from r887317, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AbstractEntryBuilder.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AbstractFeedBuilder.java
      - copied unchanged from r887317, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AbstractFeedBuilder.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AtomElementReader.java
      - copied unchanged from r887317, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AtomElementReader.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AtomElementWriter.java
      - copied unchanged from r887317, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AtomElementWriter.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomPojoProvider.java
      - copied unchanged from r887317, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomPojoProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomPojoProviderTest.java
      - copied unchanged from r887317, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomPojoProviderTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/servers.xml
      - copied unchanged from r887317, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/servers.xml
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/WebClient.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpServletResponseFilter.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
    cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:887317

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=889365&r1=889364&r2=889365&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
Thu Dec 10 18:51:25 2009
@@ -371,7 +371,7 @@
 
         InputStream inputStream = (InputStream)r.getEntity();
         if (inputStream == null) {
-            return cls == Response.class ? cls : null;
+            return cls == Response.class ? r : null;
         }
         try {
             int status = conn.getResponseCode();
@@ -379,7 +379,7 @@
                 Object length = r.getMetadata().getFirst(HttpHeaders.CONTENT_LENGTH);
                 if (length == null || Integer.parseInt(length.toString()) == 0
                     || status >= 400) {
-                    return cls == Response.class ? cls : null;
+                    return cls == Response.class ? r : cls == InputStream.class ? inputStream
: null;
                 }
             }
         } catch (IOException ex) {
@@ -550,7 +550,6 @@
         
         m.put(Message.CONTENT_TYPE, headers.getFirst(HttpHeaders.CONTENT_TYPE));
         
-        
         Exchange exchange = new ExchangeImpl();
         exchange.setSynchronous(true);
         exchange.setOutMessage(m);

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=889365&r1=889364&r2=889365&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
Thu Dec 10 18:51:25 2009
@@ -302,7 +302,7 @@
      * @param memberClass expected type of collection member class
      * @return typed collection
      */
-    public <T> Collection<T> invokeAndGetCollection(String httpMethod, Object
body, 
+    public <T> Collection<? extends T> invokeAndGetCollection(String httpMethod,
Object body, 
                                                     Class<T> memberClass) {
         
         Response r = doInvoke(httpMethod, body, Collection.class, memberClass);

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpServletResponseFilter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpServletResponseFilter.java?rev=889365&r1=889364&r2=889365&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpServletResponseFilter.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpServletResponseFilter.java
Thu Dec 10 18:51:25 2009
@@ -19,6 +19,9 @@
 package org.apache.cxf.jaxrs.impl;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
@@ -45,4 +48,29 @@
         return new ServletOutputStreamFilter(super.getOutputStream(), m);
     }
     
+    @Override
+    public void setHeader(String name, String value) {
+        setHeaderInternal(name, value, false);
+    }
+    
+    @Override
+    public void addHeader(String name, String value) {
+        setHeaderInternal(name, value, true);
+    }
+    
+    @SuppressWarnings("unchecked")
+    private void setHeaderInternal(String name, String value, boolean add) {
+        Map<String, List<String>> headers = 
+            (Map<String, List<String>>)m.get(Message.PROTOCOL_HEADERS);
+        List<String> values = headers.get(name);
+        if (values == null) {
+            values = new ArrayList<String>();
+            headers.put(name, values);
+        }
+        if (!add) {
+            values.clear();
+        }
+        values.add(value);
+    }
 }
+

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=889365&r1=889364&r2=889365&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
Thu Dec 10 18:51:25 2009
@@ -232,10 +232,19 @@
             LOG.fine("Response content type is: " + responseType.toString());
             message.put(Message.CONTENT_TYPE, responseType.toString());
             
+            Annotation[] annotations = invoked != null ? invoked.getAnnotations() : new Annotation[]{};
+            
+            long size = writer.getSize(entity, targetType, genericType, annotations, responseType);
+            if (size > 0) {
+                LOG.fine("Setting ContentLength to " + size + " as requested by " 
+                         + writer.getClass().getName());
+                responseHeaders.putSingle(HttpHeaders.CONTENT_LENGTH, Long.toString(size));
+            }
+            
             LOG.fine("Response EntityProvider is: " + writer.getClass().getName());
             try {
                 writer.writeTo(entity, targetType, genericType, 
-                               invoked != null ? invoked.getAnnotations() : new Annotation[]{},

+                               annotations, 
                                responseType, 
                                responseHeaders, 
                                message.getContent(OutputStream.class));

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java?rev=889365&r1=889364&r2=889365&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
Thu Dec 10 18:51:25 2009
@@ -41,6 +41,7 @@
 import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
 
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
@@ -48,6 +49,7 @@
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 
 @Produces("text/html")
+@Provider
 public class RequestDispatcherProvider extends AbstractConfigurableProvider
     implements MessageBodyWriter<Object> {
     

Modified: cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=889365&r1=889364&r2=889365&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Thu Dec 10 18:51:25 2009
@@ -63,6 +63,7 @@
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.AbstractConduit;
 import org.apache.cxf.transport.Destination;
@@ -2132,9 +2133,11 @@
             }
         
             
-            if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) {
+            if (responseCode == HttpURLConnection.HTTP_NOT_FOUND
+                && !MessageUtils.isTrue(outMessage.getContextualProperty(
+                    "org.apache.cxf.http.no_io_exceptions"))) {
                 throw new IOException("HTTP response '" + responseCode + ": " 
-                        + connection.getResponseMessage() + "'");
+                    + connection.getResponseMessage() + "'");
             }
 
             
@@ -2190,12 +2193,13 @@
                 List<String> cookies = connection.getHeaderFields().get("Set-Cookie");
                 Cookie.handleSetCookie(sessionCookies, cookies);
             }
-
-            in = in == null
-                 ? connection.getErrorStream() == null
-                   ? connection.getInputStream()
-                   : connection.getErrorStream()
-                 : in;
+            if (responseCode != HttpURLConnection.HTTP_NOT_FOUND) {
+                in = in == null
+                     ? connection.getErrorStream() == null
+                       ? connection.getInputStream()
+                       : connection.getErrorStream()
+                     : in;
+            }
                    
             // if (in == null) : it's perfectly ok for non-soap http services
             // have no response body : those interceptors which do need it will check anyway
       

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl.java?rev=889365&r1=889364&r2=889365&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl.java
Thu Dec 10 18:51:25 2009
@@ -29,6 +29,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;
 import javax.xml.ws.WebServiceContext;
@@ -85,9 +86,13 @@
                 details.setId(id);
                 throw new BookNotFoundFault(details);
             }
-            Response r = Response.status(returnCode).header("BOOK-HEADER", 
-                "No Book with id " + id + " is available").build();
-            throw new WebApplicationException(r);
+            String msg = "No Book with id " + id + " is available";
+            ResponseBuilder builder = Response.status(returnCode).header("BOOK-HEADER", msg);
+            
+            if (returnCode == 404) {
+                builder.type("text/plain").entity(msg);
+            }
+            throw new WebApplicationException(builder.build());
         }
         
         if (!invocationInProcess) {

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=889365&r1=889364&r2=889365&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
Thu Dec 10 18:51:25 2009
@@ -26,6 +26,7 @@
 import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -177,6 +178,22 @@
     }
     
     @Test
+    public void testNoBook357WebClient() throws Exception {
+        
+        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put("org.apache.cxf.http.throw_io_exceptions", Boolean.TRUE);
+        bean.setProperties(properties);
+        bean.setAddress("http://localhost:9092/test/services/rest/bookstore/356");
+        WebClient wc = bean.createWebClient();
+        Response response = wc.get();
+        assertEquals(404, response.getStatus());
+        String msg = IOUtils.readStringFromStream((InputStream)response.getEntity());
+        assertEquals("No Book with id 356 is available", msg);
+        
+    }
+    
+    @Test
     public void testOtherInterceptorDrainingStream() throws Exception {
 
         String baseAddress = "http://localhost:9092/test/services/rest";



Mime
View raw message