cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1336760 - in /cxf/branches/2.5.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
Date Thu, 10 May 2012 15:54:12 GMT
Author: sergeyb
Date: Thu May 10 15:54:12 2012
New Revision: 1336760

URL: http://svn.apache.org/viewvc?rev=1336760&view=rev
Log:
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.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1336734

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

Modified: cxf/branches/2.5.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.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java?rev=1336760&r1=1336759&r2=1336760&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
Thu May 10 15:54:12 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.5.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.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java?rev=1336760&r1=1336759&r2=1336760&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/search/SearchContextImplTest.java
Thu May 10 15:54:12 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(



Mime
View raw message