cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1336774 - in /cxf/branches/2.4.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/...
Date Thu, 10 May 2012 16:16:43 GMT
Author: sergeyb
Date: Thu May 10 16:16:42 2012
New Revision: 1336774

URL: http://svn.apache.org/viewvc?rev=1336774&view=rev
Log:
Merged revisions 1336749,1336760 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes

................
  r1336749 | sergeyb | 2012-05-10 16:41:27 +0100 (Thu, 10 May 2012) | 13 lines
  
  Merged revisions 1336660,1336747 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1336660 | sergeyb | 2012-05-10 14:07:48 +0100 (Thu, 10 May 2012) | 1 line
    
    [CXF-4306] Trying to handle the mix-up of FormParam and Multipart annotaions
  ........
    r1336747 | sergeyb | 2012-05-10 16:35:06 +0100 (Thu, 10 May 2012) | 1 line
    
    [CXF-4307] Setting a default in Cookie separator to ';'
  ........
................
  r1336760 | sergeyb | 2012-05-10 16:54:12 +0100 (Thu, 10 May 2012) | 9 lines
  
  Merged revisions 1336734 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1336734 | sergeyb | 2012-05-10 16:02:22 +0100 (Thu, 10 May 2012) | 1 line
    
    [CXF-4305] Getting SearchContext to enforce that only non-primitive condition types are
supported
  ........
................

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
    cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
    cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
    cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
    cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu May 10 16:16:42 2012
@@ -0,0 +1,2 @@
+/cxf/branches/2.5.x-fixes:1336749-1336760
+/cxf/trunk:1336660,1336734,1336747

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

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java?rev=1336774&r1=1336773&r2=1336774&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
Thu May 10 16:16:42 2012
@@ -21,9 +21,12 @@ package org.apache.cxf.jaxrs.ext.search;
 
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.logging.Logger;
 
 import javax.ws.rs.core.MultivaluedMap;
 
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
 
@@ -31,6 +34,7 @@ public class SearchContextImpl implement
 
     public static final String SEARCH_QUERY = "_search";
     public static final String SHORT_SEARCH_QUERY = "_s";
+    private static final Logger LOG = LogUtils.getL7dLogger(SearchContextImpl.class);
     private Message message;
     
     public SearchContextImpl(Message message) {
@@ -38,6 +42,11 @@ public class SearchContextImpl implement
     }
     
     public <T> SearchCondition<T> getCondition(Class<T> cls) {
+        if (InjectionUtils.isPrimitive(cls)) {
+            String errorMessage = "Primitive condition types are not supported";
+            LOG.warning(errorMessage);
+            throw new IllegalArgumentException(errorMessage);
+        }
         FiqlParser<T> parser = getParser(cls);
         
         String expression = getSearchExpression();
@@ -70,7 +79,6 @@ public class SearchContextImpl implement
     }
     
     private <T> FiqlParser<T> getParser(Class<T> cls) {
-        
         // we can use this method as a parser factory, ex
         // we can get parsers capable of parsing XQuery and other languages
         // depending on the properties set by a user

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java?rev=1336774&r1=1336773&r2=1336774&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/HttpHeadersImpl.java
Thu May 10 16:16:42 2012
@@ -49,6 +49,7 @@ public class HttpHeadersImpl implements 
         "org.apache.cxf.http.cookie.separator";
     private static final String COOKIE_SEPARATOR_CRLF = "crlf";
     private static final String DEFAULT_SEPARATOR = ",";
+    private static final String DEFAULT_COOKIE_SEPARATOR = ";";
     
     private static final String COMPLEX_HEADER_EXPRESSION = 
         "(([\\w]+=\"[^\"]*\")|([\\w]+=[\\w]+)|([\\w]+))(;(([\\w]+=\"[^\"]*\")|([\\w]+=[\\w]+)|([\\w]+)))?";
@@ -114,7 +115,7 @@ public class HttpHeadersImpl implements 
             return COOKIE_SEPARATOR_CRLF.equals(cookiePropValue.toString()) 
                 ? "\r\n" : cookiePropValue.toString();
         } else {
-            return DEFAULT_SEPARATOR;
+            return DEFAULT_COOKIE_SEPARATOR;
         }
     }
     

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java?rev=1336774&r1=1336773&r2=1336774&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
Thu May 10 16:16:42 2012
@@ -50,7 +50,7 @@ public final class FormUtils {
     private static final Logger LOG = LogUtils.getL7dLogger(FormUtils.class);
     private static final String MULTIPART_FORM_DATA_TYPE = "form-data";  
     private static final String MAX_FORM_PARAM_COUNT = "maxFormParameterCount";  
-        
+    private static final String CONTENT_DISPOSITION_FILES_PARAM = "files";    
     private FormUtils() {
         
     }
@@ -158,10 +158,18 @@ public final class FormUtils {
             if (StringUtils.isEmpty(name)) { 
                 throw new WebApplicationException(400);
             }
+            if (CONTENT_DISPOSITION_FILES_PARAM.equals(name)) {
+                // this is a reserved name in Content-Disposition for parts containing files
+                continue;
+            }
             try {
                 String value = IOUtils.toString(a.getDataHandler().getInputStream());
                 params.add(HttpUtils.urlDecode(name),
                            decode ? HttpUtils.urlDecode(value) : value);
+            } catch (IllegalArgumentException ex) {
+                LOG.warning("Illegal URL-encoded characters, make sure that no "
+                    + "@FormParam and @Multipart annotations are mixed up");
+                throw new WebApplicationException(415);
             } catch (IOException ex) {
                 throw new WebApplicationException(415);
             }

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java?rev=1336774&r1=1336773&r2=1336774&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
Thu May 10 16:16:42 2012
@@ -36,6 +36,11 @@ public class SearchContextImplTest exten
             SearchContextImpl.SEARCH_QUERY + "=" + "name==CXF%20Rocks;id=gt=123");
     }
     
+    @Test(expected = IllegalArgumentException.class)
+    public void testIllegalConditionType() {
+        SearchContext context = new SearchContextImpl(new MessageImpl());
+        context.getCondition(String.class);
+    }
     @Test
     public void testFiqlSearchConditionWithShortQuery() {
         doTestFiqlSearchCondition(

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java?rev=1336774&r1=1336773&r2=1336774&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/HttpHeadersImplTest.java
Thu May 10 16:16:42 2012
@@ -240,7 +240,7 @@ public class HttpHeadersImplTest extends
         Message m = new MessageImpl();
         m.setExchange(new ExchangeImpl());
         MetadataMap<String, String> headers = createHeaders();
-        headers.putSingle(HttpHeaders.COOKIE, "a=b,c=d");
+        headers.putSingle(HttpHeaders.COOKIE, "a=b;c=d");
         m.put(Message.PROTOCOL_HEADERS, headers);
         HttpHeaders h = new HttpHeadersImpl(m);
         Map<String, Cookie> cookies = h.getCookies();
@@ -250,15 +250,15 @@ public class HttpHeadersImplTest extends
     }
     
     @Test
-    public void testGetCookiesWithSemiColon() throws Exception {
+    public void testGetCookiesWithComma() throws Exception {
         
         Message m = new MessageImpl();
         Exchange ex = new ExchangeImpl();
         ex.setInMessage(m);
-        ex.put("org.apache.cxf.http.cookie.separator", ";");
+        ex.put("org.apache.cxf.http.cookie.separator", ",");
         m.setExchange(ex);
         MetadataMap<String, String> headers = createHeaders();
-        headers.putSingle(HttpHeaders.COOKIE, "a=b" + ";" + "c=d");
+        headers.putSingle(HttpHeaders.COOKIE, "a=b,c=d");
         m.put(Message.PROTOCOL_HEADERS, headers);
         HttpHeaders h = new HttpHeadersImpl(m);
         Map<String, Cookie> cookies = h.getCookies();

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=1336774&r1=1336773&r2=1336774&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Thu May 10 16:16:42 2012
@@ -753,7 +753,7 @@ public class JAXRSUtilsTest extends Asse
         Method m = Customer.class.getMethod("testMultipleCookieParam", argType);
         MessageImpl messageImpl = new MessageImpl();
         MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
-        headers.add("Cookie", "c1=c1Value, c2=c2Value");
+        headers.add("Cookie", "c1=c1Value; c2=c2Value");
         headers.add("Cookie", "c3=c3Value");
         messageImpl.put(Message.PROTOCOL_HEADERS, headers);
         List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null),

Modified: cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1336774&r1=1336773&r2=1336774&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Thu May 10 16:16:42 2012
@@ -1761,7 +1761,7 @@ public class JAXRSClientServerBookTest e
                                int expectedStatus) throws Exception {
         GetMethod get = new GetMethod(address);
         get.setRequestHeader("Accept", acceptType);
-        get.addRequestHeader("Cookie", "a=b,c=d");
+        get.addRequestHeader("Cookie", "a=b;c=d");
         get.addRequestHeader("Cookie", "e=f");
         get.setRequestHeader("Accept-Language", "da;q=0.8,en");
         get.setRequestHeader("Book", "1,2,3");

Modified: cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java?rev=1336774&r1=1336773&r2=1336774&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
(original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
Thu May 10 16:16:42 2012
@@ -135,6 +135,12 @@ public class JAXRSMultipartTest extends 
     }
     
     @Test
+    public void testBookJSONFormTwoFilesMixUp() throws Exception {
+        String address = "http://localhost:" + PORT + "/bookstore/books/filesform/mixup";
+        doAddFormBook(address, "attachmentFormJsonFiles", 200);               
+    }
+    
+    @Test
     public void testBookJSONFormOneFile() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/books/fileform";
         doAddFormBook(address, "attachmentFormJsonFile", 200);               

Modified: cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java?rev=1336774&r1=1336773&r2=1336774&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
(original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
Thu May 10 16:16:42 2012
@@ -412,7 +412,7 @@ public class MultipartStore {
         Book b1 = books.get(0);
         Book b2 = books.get(1);
         if (!"CXF in Action - 1".equals(b1.getName())
-            || !"CXF in Action - 2".equals(b2.getName())
+            || !"CXF in Action - 2%".equals(b2.getName())
             || !"Larry".equals(name)) {
             throw new WebApplicationException();
         }
@@ -422,6 +422,16 @@ public class MultipartStore {
     }
     
     @POST
+    @Path("/books/filesform/mixup")
+    @Produces("text/xml")
+    @Consumes("multipart/form-data")
+    public Response addBookFilesFormMixUp(@FormParam("owner") String name, 
+                                          @Multipart("files") List<Book> books)
+        throws Exception {
+        return addBookFilesForm(name, books);
+    }
+    
+    @POST
     @Path("/books/fileform")
     @Produces("text/xml")
     @Consumes("multipart/form-data")

Modified: cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles?rev=1336774&r1=1336773&r2=1336774&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles
(original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles
Thu May 10 16:16:42 2012
@@ -19,6 +19,6 @@ Content-Disposition: form-data; name="bo
 Content-Type: application/json; charset=US-ASCII
 Content-Transfer-Encoding: 8bit
 
-{"Book":{"name":"CXF in Action - 2","id":124}}
+{"Book":{"name":"CXF in Action - 2%","id":124}}
 --_Part_4_701508.1145579811786--
 --bqJky99mlBWa-ZuqjC53mG6EzbmlxB--
\ No newline at end of file



Mime
View raw message