cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1493816 - in /cxf/branches/2.7.x-fixes: ./ rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
Date Mon, 17 Jun 2013 15:38:55 GMT
Author: sergeyb
Date: Mon Jun 17 15:38:55 2013
New Revision: 1493816

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

........
  r1493813 | sergeyb | 2013-06-17 16:34:20 +0100 (Mon, 17 Jun 2013) | 1 line
  
  [CXF-5081] Support for custom FIQL query names
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
    cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java

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

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

Modified: cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java?rev=1493816&r1=1493815&r2=1493816&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
Mon Jun 17 15:38:55 2013
@@ -41,6 +41,7 @@ public class SearchContextImpl implement
 
     public static final String SEARCH_QUERY = "_search";
     public static final String SHORT_SEARCH_QUERY = "_s";
+    public static final String CUSTOM_SEARCH_QUERY_PARAM_NAME = "search.query.parameter.name";
     private static final String USE_PLAIN_QUERY_PARAMETERS = "search.use.plain.queries";
     private static final String USE_ALL_QUERY_COMPONENT = "search.use.all.query.component";
     private static final Logger LOG = LogUtils.getL7dLogger(SearchContextImpl.class);
@@ -109,6 +110,10 @@ public class SearchContextImpl implement
             }
             MultivaluedMap<String, String> params = 
                 JAXRSUtils.getStructuredParams(queryStr, "&", true, false);
+            String customQueryParamName = (String)message.getContextualProperty(CUSTOM_SEARCH_QUERY_PARAM_NAME);
+            if (customQueryParamName != null) {
+                return params.getFirst(customQueryParamName);
+            }
             if (queryStr.contains(SHORT_SEARCH_QUERY) || queryStr.contains(SEARCH_QUERY))
{
                 if (params.containsKey(SHORT_SEARCH_QUERY)) {
                     return params.getFirst(SHORT_SEARCH_QUERY);

Modified: cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java?rev=1493816&r1=1493815&r2=1493816&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
Mon Jun 17 15:38:55 2013
@@ -83,6 +83,14 @@ public class SearchContextImplTest exten
     }
     
     @Test
+    public void testFiqlSearchConditionCustomQueryName() {
+        Message m = new MessageImpl();
+        m.put(SearchContextImpl.CUSTOM_SEARCH_QUERY_PARAM_NAME, "thequery");
+        doTestFiqlSearchCondition(m,
+            "thequery" + "=" + "name==CXF%20Rocks;id=gt=123");
+    }
+    
+    @Test
     public void testFiqlSearchBean() {
         doTestFiqlSearchBean(
             SearchContextImpl.SEARCH_QUERY + "=" + "name==CXF%20Rocks;id=gt=123");
@@ -110,7 +118,10 @@ public class SearchContextImplTest exten
     }
     
     private void doTestFiqlSearchCondition(String queryString) {
-        Message m = new MessageImpl();
+        doTestFiqlSearchCondition(new MessageImpl(), queryString);
+    }
+    
+    private void doTestFiqlSearchCondition(Message m, String queryString) {
         m.put(Message.QUERY_STRING, queryString);
         SearchContext context = new SearchContextImpl(m);
         SearchCondition<Book> sc = context.getCondition(Book.class);



Mime
View raw message