cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: Minor updates to the search parser to beter control the encoding/decoding process
Date Wed, 09 Jul 2014 10:10:15 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 51546af28 -> 5f76a5316


Minor updates to the search parser to beter control the encoding/decoding process


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/5f76a531
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/5f76a531
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/5f76a531

Branch: refs/heads/2.7.x-fixes
Commit: 5f76a53165b4136e70a72065105b872ea5719177
Parents: 51546af
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Jul 9 11:00:26 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Jul 9 11:09:48 2014 +0100

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/ext/search/SearchContextImpl.java  |  9 ++++++++-
 .../org/apache/cxf/jaxrs/ext/search/SearchUtils.java    |  1 +
 .../apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java    | 12 ++++++++++--
 3 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/5f76a531/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
index bacd4cf..9130577 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
@@ -46,6 +46,7 @@ public class SearchContextImpl implements SearchContext {
     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 String BLOCK_SEARCH_EXCEPTION = "search.block.search.exception";
+    private static final String KEEP_QUERY_ENCODED = "search.keep.query.encoded";
     private static final Logger LOG = LogUtils.getL7dLogger(SearchContextImpl.class);
     private Message message;
     
@@ -115,8 +116,10 @@ public class SearchContextImpl implements SearchContext {
             if (MessageUtils.isTrue(message.getContextualProperty(USE_ALL_QUERY_COMPONENT)))
{
                 return queryStr;
             }
+            boolean encoded = PropertyUtils.isTrue(getKeepEncodedProperty());
+            
             MultivaluedMap<String, String> params = 
-                JAXRSUtils.getStructuredParams(queryStr, "&", true, false);
+                JAXRSUtils.getStructuredParams(queryStr, "&", !encoded, false);
             String customQueryParamName = (String)message.getContextualProperty(CUSTOM_SEARCH_QUERY_PARAM_NAME);
             if (customQueryParamName != null) {
                 return params.getFirst(customQueryParamName);
@@ -145,6 +148,10 @@ public class SearchContextImpl implements SearchContext {
         return builder.and(list).query();
     }
     
+    private String getKeepEncodedProperty() {
+        return (String)message.getContextualProperty(KEEP_QUERY_ENCODED);
+    }
+    
     private CompleteCondition getOrCondition(SearchConditionBuilder builder,
                                              Map.Entry<String, List<String>>
entry) {
         String key = entry.getKey();

http://git-wip-us.apache.org/repos/asf/cxf/blob/5f76a531/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
index 773395e..d4dbc59 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
@@ -31,6 +31,7 @@ public final class SearchUtils {
     public static final String LAX_PROPERTY_MATCH = "search.lax.property.match";
     public static final String BEAN_PROPERTY_MAP = "search.bean.property.map";
     public static final String SEARCH_VISITOR_PROPERTY = "search.visitor";
+    public static final String DECODE_QUERY_VALUES = "search.decode.values";
     
     private SearchUtils() {
         

http://git-wip-us.apache.org/repos/asf/cxf/blob/5f76a531/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
index 937aba5..39ad123 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
@@ -36,7 +36,8 @@ import java.util.regex.Pattern;
 
 import javax.xml.datatype.DatatypeConfigurationException;
 import javax.xml.datatype.DatatypeFactory;
-
+import org.apache.cxf.common.util.PropertyUtils;
+import org.apache.cxf.common.util.UrlUtils;
 import org.apache.cxf.jaxrs.ext.search.AndSearchCondition;
 import org.apache.cxf.jaxrs.ext.search.Beanspector;
 import org.apache.cxf.jaxrs.ext.search.Beanspector.TypeInfo;
@@ -313,6 +314,9 @@ public class FiqlParser<T> implements SearchConditionParser<T>
{
             TypeInfo typeInfo = 
                 beanspector != null ? beanspector.getAccessorTypeInfo(name) 
                     : new TypeInfo(String.class, String.class);
+            if (isDecodeQueryValues()) {
+                value = UrlUtils.urlDecode(value);
+            } 
             Object object = parseType(originalName, null, null, setter, typeInfo, value);
             return new TypeInfoObject(object, typeInfo);
         } catch (Exception e) {
@@ -550,7 +554,11 @@ public class FiqlParser<T> implements SearchConditionParser<T>
{
             return Character.toUpperCase(name.charAt(0)) + name.substring(1);
         }
     }
-    
+ 
+    protected Boolean isDecodeQueryValues() {
+        return PropertyUtils.isTrue(contextProperties.get(SearchUtils.DECODE_QUERY_VALUES));
+    }
+   
     // node of abstract syntax tree
     private interface ASTNode<T> {
         SearchCondition<T> build() throws SearchParseException;


Mime
View raw message