cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1359784 - in /cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search: SearchConditionParser.java SearchContext.java SearchContextImpl.java
Date Tue, 10 Jul 2012 16:58:05 GMT
Author: sergeyb
Date: Tue Jul 10 16:58:05 2012
New Revision: 1359784

URL: http://svn.apache.org/viewvc?rev=1359784&view=rev
Log:
[CXF-4415] Missing updates

Modified:
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java

Modified: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java?rev=1359784&r1=1359783&r2=1359784&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchConditionParser.java
Tue Jul 10 16:58:05 2012
@@ -18,6 +18,10 @@
  */
 package org.apache.cxf.jaxrs.ext.search;
 
+/**
+ * Search Language Parser implementation.
+ * FIQL Language parser is the default implementation. 
+ */
 public interface SearchConditionParser<T> {
     SearchCondition<T> parse(String fiqlExpression) throws SearchParseException;
 }

Modified: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java?rev=1359784&r1=1359783&r2=1359784&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java
Tue Jul 10 16:58:05 2012
@@ -19,12 +19,14 @@
 package org.apache.cxf.jaxrs.ext.search;
 
 /**
- * Represents the current search expression
+ * Represents the current search expression.
  */
 public interface SearchContext {
     
     /**
-     * Returns the typed search condition representing the search expression
+     * Returns the typed search condition representing 
+     * the search expression which is extracted from 
+     * the request URI
      * 
      * @param cls the type of the bean(s) the new search condition will 
      *        attempt to match
@@ -34,8 +36,21 @@ public interface SearchContext {
     
     
     /**
-     * Returns the actual query expression
-     * @return the expression
+     * Returns the typed search condition representing 
+     * the provided search expression
+     * 
+     * @param expression the search expression
+     * @param cls the type of the bean(s) the new search condition will 
+     *        attempt to match
+     * @return the search condition
+     */
+    <T> SearchCondition<T> getCondition(String expression, Class<T> cls);
+    
+    
+    /**
+     * Returns the search expression
+     * @return the expression which is extracted from 
+     *         the request URI, can be null
      */
     String getSearchExpression();
 }

Modified: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java?rev=1359784&r1=1359783&r2=1359784&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
Tue Jul 10 16:58:05 2012
@@ -43,6 +43,10 @@ public class SearchContextImpl implement
     }
     
     public <T> SearchCondition<T> getCondition(Class<T> cls) {
+        return getCondition(null, cls);
+    }
+    
+    public <T> SearchCondition<T> getCondition(String expression, Class<T>
cls) {
         
         if (InjectionUtils.isPrimitive(cls)) {
             String errorMessage = "Primitive condition types are not supported"; 
@@ -52,10 +56,11 @@ public class SearchContextImpl implement
         
         SearchConditionParser<T> parser = getParser(cls);
         
-        String expression = getSearchExpression();
-        if (expression != null) {
+        String theExpression = expression == null 
+            ? getSearchExpression() : expression;
+        if (theExpression != null) {
             try {
-                return parser.parse(expression);
+                return parser.parse(theExpression);
             } catch (SearchParseException ex) {
                 return null;
             }
@@ -66,6 +71,7 @@ public class SearchContextImpl implement
     }
 
     public String getSearchExpression() {
+        
         String queryStr = (String)message.get(Message.QUERY_STRING);
         if (queryStr != null 
             && (queryStr.contains(SHORT_SEARCH_QUERY) || queryStr.contains(SEARCH_QUERY)))
{
@@ -81,7 +87,7 @@ public class SearchContextImpl implement
         }
     }
     
-    private <T> FiqlParser<T> getParser(Class<T> cls) {
+    private <T> SearchConditionParser<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



Mime
View raw message