cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1065578 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/
Date Mon, 31 Jan 2011 12:27:34 GMT
Author: sergeyb
Date: Mon Jan 31 12:27:34 2011
New Revision: 1065578

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

........
  r1065577 | sergeyb | 2011-01-31 12:24:29 +0000 (Mon, 31 Jan 2011) | 1 line
  
  [CXF-3298] Use explicit indexOf and substring functions for creating the query map
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 31 12:27:34 2011
@@ -1 +1 @@
-/cxf/trunk:1063042,1063205,1063267,1063340,1064095
+/cxf/trunk:1063042,1063205,1063267,1063340,1064095,1065577

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

Modified: cxf/branches/2.3.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.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java?rev=1065578&r1=1065577&r2=1065578&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
Mon Jan 31 12:27:34 2011
@@ -19,7 +19,9 @@
 
 package org.apache.cxf.jaxrs.ext.search;
 
-import org.apache.cxf.jaxrs.utils.HttpUtils;
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
 
 public class SearchContextImpl implements SearchContext {
@@ -51,13 +53,17 @@ public class SearchContextImpl implement
     private String getExpression() {
         String queryStr = (String)message.get(Message.QUERY_STRING);
         if (queryStr != null 
-            && (queryStr.startsWith(SEARCH_QUERY) || queryStr.startsWith(SHORT_SEARCH_QUERY)))
{
-            int ind = queryStr.indexOf('=');
-            if (ind + 1 < queryStr.length()) {
-                return HttpUtils.urlDecode(queryStr.substring(ind + 1));
+            && (queryStr.contains(SHORT_SEARCH_QUERY) || queryStr.contains(SEARCH_QUERY)))
{
+            MultivaluedMap<String, String> params = 
+                JAXRSUtils.getStructuredParams(queryStr, "&", true, false);
+            if (params.containsKey(SHORT_SEARCH_QUERY)) {
+                return params.getFirst(SHORT_SEARCH_QUERY);
+            } else {
+                return params.getFirst(SEARCH_QUERY);
             }
+        } else {
+            return null;
         }
-        return null;
     }
     
     private <T> FiqlParser<T> getParser(Class<T> cls) {

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1065578&r1=1065577&r2=1065578&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
Mon Jan 31 12:27:34 2011
@@ -937,17 +937,21 @@ public final class JAXRSUtils {
         if (!StringUtils.isEmpty(query)) {            
             List<String> parts = Arrays.asList(query.split(sep));
             for (String part : parts) {
-                String[] values = part.split("=");
+                int index = part.indexOf('=');
+                String name = null;
                 String value = null;
-                if (values.length == 1) {
+                if (index == -1) {
+                    name = part;
                     value = "";
-                } else if (decode || (decodePlus && values[1].contains("+"))) {
-                    value = (";".equals(sep))
-                        ? HttpUtils.pathDecode(values[1]) : HttpUtils.urlDecode(values[1]);

                 } else {
-                    value = values[1];
+                    name = part.substring(0, index);
+                    value =  index < part.length() ? part.substring(index + 1) : "";
+                    if (decode || (decodePlus && value.contains("+"))) {
+                        value = (";".equals(sep))
+                            ? HttpUtils.pathDecode(value) : HttpUtils.urlDecode(value); 
+                    }
                 }
-                queries.add(HttpUtils.urlDecode(values[0]), value);
+                queries.add(HttpUtils.urlDecode(name), value);
             }
         }
     }

Modified: cxf/branches/2.3.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.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java?rev=1065578&r1=1065577&r2=1065578&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
Mon Jan 31 12:27:34 2011
@@ -32,19 +32,29 @@ public class SearchContextImplTest exten
 
     @Test
     public void testFiqlSearchCondition() {
-        doTestFiqlSearchCondition(SearchContextImpl.SEARCH_QUERY,
-                                  "name==CXF%20Rocks;id=gt=123");
+        doTestFiqlSearchCondition(
+            SearchContextImpl.SEARCH_QUERY + "=" + "name==CXF%20Rocks;id=gt=123");
     }
     
     @Test
     public void testFiqlSearchConditionWithShortQuery() {
-        doTestFiqlSearchCondition(SearchContextImpl.SHORT_SEARCH_QUERY,
-                                  "name==CXF%20Rocks;id=gt=123");
+        doTestFiqlSearchCondition(
+            SearchContextImpl.SHORT_SEARCH_QUERY + "=" + "name==CXF%20Rocks;id=gt=123");
     }
     
-    private void doTestFiqlSearchCondition(String queryName, String queryValue) {
+    @Test
+    public void testFiqlSearchConditionWithNonFiqlQuery() {
+        doTestFiqlSearchCondition(
+            "_s=name==CXF%20Rocks;id=gt=123&a=b");
+        doTestFiqlSearchCondition(
+            "a=b&_s=name==CXF%20Rocks;id=gt=123");
+        doTestFiqlSearchCondition(
+            "a=b&_s=name==CXF%20Rocks;id=gt=123&c=d");
+    }
+    
+    private void doTestFiqlSearchCondition(String queryString) {
         Message m = new MessageImpl();
-        m.put(Message.QUERY_STRING, queryName + "=" + queryValue);
+        m.put(Message.QUERY_STRING, queryString);
         SearchContext context = new SearchContextImpl(m);
         SearchCondition<Book> sc = context.getCondition(Book.class);
         assertNotNull(sc);



Mime
View raw message