cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1536747 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/
Date Tue, 29 Oct 2013 15:20:16 GMT
Author: sergeyb
Date: Tue Oct 29 15:20:15 2013
New Revision: 1536747

URL: http://svn.apache.org/r1536747
Log:
[CXF-5347] Making sure matrix params do not interfere with RequestPreprocessor handling extensions

Added:
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_atom_book_json_matrix.txt
  (with props)
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAtomBookTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java?rev=1536747&r1=1536746&r2=1536747&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java
Tue Oct 29 15:20:15 2013
@@ -56,6 +56,15 @@ public class PathSegmentImpl implements 
         return path;
     }
     
+    public String getMatrixString() {
+        int index = path.indexOf(';');
+        if (index == -1) {
+            return null;
+        } else {
+            return path.substring(index);
+        }
+    }
+    
     public String toString() {
         return path;
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java?rev=1536747&r1=1536746&r2=1536747&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
Tue Oct 29 15:20:15 2013
@@ -79,23 +79,31 @@ public class RequestPreprocessor {
     }
     
     private void handleLanguageMappings(Message m, UriInfo uriInfo) {
-        String path = uriInfo.getPath(false);
+        if (languageMappings.isEmpty()) {
+            return;
+        }
+        PathSegmentImpl ps = new PathSegmentImpl(uriInfo.getPath(false));
+        String path = ps.getPath();
         for (Map.Entry<?, ?> entry : languageMappings.entrySet()) {
             if (path.endsWith("." + entry.getKey())) {
                 updateAcceptLanguageHeader(m, entry.getValue().toString());
-                updatePath(m, path, entry.getKey().toString());
+                updatePath(m, path, entry.getKey().toString(), ps.getMatrixString());
                 break;
             }    
         }
     }
     
     private void handleExtensionMappings(Message m, UriInfo uriInfo) {
-        String path = uriInfo.getPath(false);
+        if (extensionMappings.isEmpty()) {
+            return;
+        }
+        PathSegmentImpl ps = new PathSegmentImpl(uriInfo.getPath(false));
+        String path = ps.getPath();
         for (Map.Entry<?, ?> entry : extensionMappings.entrySet()) {
             String key = entry.getKey().toString();
             if (path.endsWith("." + key)) {
                 updateAcceptTypeHeader(m, entry.getValue().toString());
-                updatePath(m, path, key);
+                updatePath(m, path, key, ps.getMatrixString());
                 if ("wadl".equals(key)) {
                     // the path has been updated and Accept was not necessarily set to 
                     // WADL type (xml or json or html - other options)
@@ -126,8 +134,11 @@ public class RequestPreprocessor {
             .put(HttpHeaders.ACCEPT_LANGUAGE, acceptLanguage);
     }
     
-    private void updatePath(Message m, String path, String suffix) {
+    private void updatePath(Message m, String path, String suffix, String matrixString) {
         String newPath = path.substring(0, path.length() - (suffix.length() + 1));
+        if (matrixString != null) {
+            newPath += matrixString;
+        }
         HttpUtils.updatePath(m, newPath);
     }
     

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAtomBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAtomBookTest.java?rev=1536747&r1=1536746&r2=1536747&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAtomBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAtomBookTest.java
Tue Oct 29 15:20:15 2013
@@ -100,6 +100,10 @@ public class JAXRSAtomBookTest extends A
         getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/entries/123.json",
                                "resources/expected_atom_book_json.txt",
                                "*/*");
+        // do the same using extension mappings & matrix parameters
+        getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/entries/123.json;a=b",
+                               "resources/expected_atom_book_json_matrix.txt",
+                               "*/*");
         
         
     }

Added: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_atom_book_json_matrix.txt
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_atom_book_json_matrix.txt?rev=1536747&view=auto
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_atom_book_json_matrix.txt
(added)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_atom_book_json_matrix.txt
Tue Oct 29 15:20:15 2013
@@ -0,0 +1,14 @@
+{
+ "id":"123",
+ "title":"CXF in Action",
+ "content":{
+  "attributes":{
+   "type":"application/xml"
+  },
+  "children":["<Book><id>123<\/id><name>CXF in Action<\/name><\/Book>"
+  ]
+ },
+ "attributes":{
+  "xml:base":"http://localhost:9080/bookstore/bookstore/books/entries/123;a=b"
+ }
+}
\ No newline at end of file

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_atom_book_json_matrix.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_atom_book_json_matrix.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message