cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1468396 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/j...
Date Tue, 16 Apr 2013 12:36:39 GMT
Author: sergeyb
Date: Tue Apr 16 12:36:39 2013
New Revision: 1468396

URL: http://svn.apache.org/r1468396
Log:
Merged revisions 1466840 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1466840 | sergeyb | 2013-04-11 12:59:00 +0100 (Thu, 11 Apr 2013) | 1 line
  
  [CXF-4950] Avoiding checking Consumes in case of GET and few other minor updaes
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1466840

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

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=1468396&r1=1468395&r2=1468396&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
Tue Apr 16 12:36:39 2013
@@ -130,7 +130,7 @@ public class JAXRSInInterceptor extends 
         
         String requestContentType = (String)message.get(Message.CONTENT_TYPE);
         if (requestContentType == null) {
-            requestContentType = "*/*";
+            requestContentType = MediaType.WILDCARD;
         }
         
         String rawPath = HttpUtils.getPathToMatch(message, true);

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java?rev=1468396&r1=1468395&r2=1468396&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
Tue Apr 16 12:36:39 2013
@@ -22,6 +22,7 @@ package org.apache.cxf.jaxrs.model;
 import java.util.Comparator;
 import java.util.List;
 
+import javax.ws.rs.HttpMethod;
 import javax.ws.rs.core.MediaType;
 
 import org.apache.cxf.endpoint.Endpoint;
@@ -31,15 +32,16 @@ import org.apache.cxf.message.Message;
 
 public class OperationResourceInfoComparator implements Comparator<OperationResourceInfo>
{
     
-    private static final String HEAD_METHOD = "HEAD";
-    private boolean headMethod;
+    private String httpMethod;
+    private boolean getMethod;
     private Message message;
     private ResourceComparator rc;  
     private MediaType contentType;
     private List<MediaType> acceptTypes;
 
     public OperationResourceInfoComparator(Message m, 
-                                           String method, 
+                                           String httpMethod,
+                                           boolean getMethod,
                                            MediaType contentType,
                                            List<MediaType> acceptTypes) {
         this.message = m;
@@ -49,9 +51,10 @@ public class OperationResourceInfoCompar
                 rc = (ResourceComparator)o;
             }
         }
-        headMethod = HEAD_METHOD.equals(method);
         this.contentType = contentType;
         this.acceptTypes = acceptTypes;
+        this.httpMethod = httpMethod;
+        this.getMethod = getMethod;
     }
     
     public int compare(OperationResourceInfo e1, OperationResourceInfo e2) {
@@ -63,10 +66,10 @@ public class OperationResourceInfoCompar
             }
         }
         
-        if (headMethod) {
-            if (HEAD_METHOD.equals(e1.getHttpMethod())) {
+        if (!getMethod && HttpMethod.HEAD.equals(httpMethod)) {
+            if (HttpMethod.HEAD.equals(e1.getHttpMethod())) {
                 return -1;
-            } else if (HEAD_METHOD.equals(e2.getHttpMethod())) {
+            } else if (HttpMethod.HEAD.equals(e2.getHttpMethod())) {
                 return 1;
             }
         }
@@ -81,7 +84,7 @@ public class OperationResourceInfoCompar
             return e1.getHttpMethod() != null ? -1 : 1;
         }
         
-        if (result == 0) {
+        if (result == 0 && !getMethod) {
         
             result = JAXRSUtils.compareSortedConsumesMediaTypes(
                           e1.getConsumeTypes(), 

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1468396&r1=1468395&r2=1468396&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
Tue Apr 16 12:36:39 2013
@@ -380,16 +380,19 @@ public final class JAXRSUtils {
             path = "/";
         }
         
+        final boolean getMethod = HttpMethod.GET.equals(httpMethod);
+        
         MediaType requestType;
         try {
-            requestType = toMediaType(requestContentType);
+            requestType = getMethod ? MediaType.WILDCARD_TYPE : toMediaType(requestContentType);
         } catch (IllegalArgumentException ex) {
             throw new NotSupportedException(ex);
         }
         
         SortedMap<OperationResourceInfo, MultivaluedMap<String, String>> candidateList
= 
             new TreeMap<OperationResourceInfo, MultivaluedMap<String, String>>(
-                new OperationResourceInfoComparator(message, httpMethod, requestType, acceptContentTypes));
+                new OperationResourceInfoComparator(message, httpMethod, 
+                                                    getMethod, requestType, acceptContentTypes));
 
         int pathMatched = 0;
         int methodMatched = 0;
@@ -411,22 +414,10 @@ public final class JAXRSUtils {
                         if (matchHttpMethod(ori.getHttpMethod(), httpMethod)) {
                             methodMatched++;
                             //CHECKSTYLE:OFF
-                            if (matchConsumeTypes(requestType, ori)) {
+                            if (getMethod || matchConsumeTypes(requestType, ori)) {
                                 consumeMatched++;
                                 for (MediaType acceptType : acceptContentTypes) {
-                                    MediaType pMediaType = matchProduceTypes(acceptType,
ori);
-                                    if (pMediaType != null) {
-                                        if (acceptContentTypes.size() > 1 
-                                            || ori.getProduceTypes().size() > 1) {
-                                            pMediaType = intersectSortMediaTypes(acceptContentTypes,
-                                                                                 ori.getProduceTypes(),
-                                                                                 false).get(0);
-                                        }
-                                        map.putSingle(Message.CONTENT_TYPE, 
-                                                      mediaTypeToString(pMediaType, 
-                                                                        MEDIA_TYPE_Q_PARAM,

-                                                                        MEDIA_TYPE_QS_PARAM));
-                                        
+                                    if (matchProduceTypes(acceptType, ori)) {
                                         candidateList.put(ori, map);
                                         added = true;
                                         break;
@@ -435,8 +426,8 @@ public final class JAXRSUtils {
                             }
                             //CHECKSTYLE:ON
                         }
-                    }    
-                }
+                    }
+                }    
             } 
             if (isFineLevelLoggable) {
                 if (added) {
@@ -467,10 +458,12 @@ public final class JAXRSUtils {
                                resource.getServiceClass().getName()).toString());
             }
             if (!ori.isSubResourceLocator()) {
-                List<String> responseContentType = values.remove(Message.CONTENT_TYPE);
-                if (responseContentType != null) {
-                    message.getExchange().put(Message.CONTENT_TYPE, responseContentType.get(0));
-                }
+                MediaType responseMediaType = intersectSortMediaTypes(acceptContentTypes,
+                                                                      ori.getProduceTypes(),
+                                                                      false).get(0);
+                message.getExchange().put(Message.CONTENT_TYPE, mediaTypeToString(responseMediaType,

+                                                                                  MEDIA_TYPE_Q_PARAM,

+                                                                                  MEDIA_TYPE_QS_PARAM));
             }
             return ori;
         }
@@ -1337,13 +1330,10 @@ public final class JAXRSUtils {
         return !intersectMimeTypes(ori.getConsumeTypes(), requestContentType).isEmpty();
     }
     
-    public static MediaType matchProduceTypes(MediaType acceptContentType, 
+    public static boolean matchProduceTypes(MediaType acceptContentType, 
                                               OperationResourceInfo ori) {
         
-        List<MediaType> types = intersectMimeTypes(ori.getProduceTypes(), 
-                                                   Collections.singletonList(acceptContentType),
-                                                   true);
-        return types.isEmpty() ? null : types.get(0);
+        return !intersectMimeTypes(ori.getProduceTypes(), acceptContentType).isEmpty();
     }
     
     public static boolean matchMimeTypes(MediaType requestContentType, 

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1468396&r1=1468395&r2=1468396&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Tue Apr 16 12:36:39 2013
@@ -887,7 +887,7 @@ public class BookStore {
     
     @GET
     @Path("/books/{bookId}/")
-    @Produces("application/json;q=0.9")
+    @Produces("application/json;qs=0.9")
     public Book getBookAsJSON() throws BookNotFoundFault {
         return doGetBook(currentBookId);
     }



Mime
View raw message