You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2016/09/13 10:55:12 UTC

svn commit: r1760528 - /ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java

Author: jacopoc
Date: Tue Sep 13 10:55:12 2016
New Revision: 1760528

URL: http://svn.apache.org/viewvc?rev=1760528&view=rev
Log:
Improved: set the character encoding to the system default (UTF-8) if and only 
if it is not set already by the client.

Before this change the filter used to override the character encoding, even if 
it was specified in the http request.
Also removed some unused imports and comments.


Modified:
    ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java

Modified: ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java?rev=1760528&r1=1760527&r2=1760528&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java (original)
+++ ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java Tue Sep 13 10:55:12 2016
@@ -21,16 +21,13 @@ package org.apache.ofbiz.webapp.control;
 import static org.apache.ofbiz.base.util.UtilGenerics.checkMap;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.util.Enumeration;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
@@ -50,12 +47,8 @@ import org.apache.ofbiz.entity.GenericVa
 import org.apache.ofbiz.entity.util.EntityQuery;
 import org.apache.ofbiz.entity.util.EntityUtil;
 import org.apache.ofbiz.security.Security;
-import org.apache.ofbiz.security.SecurityConfigurationException;
-import org.apache.ofbiz.security.SecurityFactory;
 import org.apache.ofbiz.service.LocalDispatcher;
-import org.apache.ofbiz.service.ServiceContainer;
 import org.apache.ofbiz.webapp.WebAppUtil;
-import org.apache.ofbiz.webapp.event.RequestBodyMapHandlerFactory;
 import org.apache.ofbiz.webapp.website.WebSiteWorker;
 
 /**
@@ -69,6 +62,9 @@ public class ContextFilter implements Fi
     protected FilterConfig config = null;
     protected boolean debug = false;
 
+    // default charset used to decode requests body data if no encoding is specified in the request
+    private String defaultCharacterEncoding;
+
     /**
      * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
      */
@@ -84,6 +80,10 @@ public class ContextFilter implements Fi
             debug = Debug.verboseOn();
         }
 
+        defaultCharacterEncoding = config.getServletContext().getInitParameter("charset");
+        if (UtilValidate.isEmpty(defaultCharacterEncoding)) {
+            defaultCharacterEncoding = "UTF-8";
+        }
         // check the serverId
         getServerId();
         // initialize the delegator
@@ -104,7 +104,6 @@ public class ContextFilter implements Fi
         HttpServletRequest httpRequest = (HttpServletRequest) request;
         HttpServletResponse httpResponse = (HttpServletResponse) response;
 
-        // Debug.logInfo("Running ContextFilter.doFilter", module);
 
         // ----- Servlet Object Setup -----
 
@@ -250,10 +249,13 @@ public class ContextFilter implements Fi
             }
         }
 
+        if (request.getCharacterEncoding() == null) {
+            request.setCharacterEncoding(defaultCharacterEncoding);
+        }
+        WebAppUtil.setAttributesFromRequestBody(request);
+
         // check if multi tenant is enabled
         boolean useMultitenant = EntityUtil.isMultiTenantEnabled();
-        WebAppUtil.setCharacterEncoding(request);
-        WebAppUtil.setAttributesFromRequestBody(request);
         if (useMultitenant) {
             // get tenant delegator by domain name
             String serverName = httpRequest.getServerName();



Re: svn commit: r1760528 - /ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control /ContextFilter.java

Posted by Jacopo Cappellato <ja...@hotwaxsystems.com>.
cool, thanks

Jacopo

On Tue, Sep 13, 2016 at 2:56 PM, Jacques Le Roux <
jacques.le.roux@les7arts.com> wrote:

> Tests passed, must have been a BuildBot quirk
>
> https://ci.apache.org/builders/ofbiz-trunk/builds/1416
>
> Jacques
>
>
>
> Le 13/09/2016 à 14:48, Jacques Le Roux a écrit :
>
>> Works also locally here, I have forced a new build on BuildBot, could be
>> a temporary error, happens rarely but happens.
>>
>> Jacques
>>
>>
>> Le 13/09/2016 à 13:43, Jacopo Cappellato a écrit :
>>
>>> Yeah, thanks for the notification, I also saw the automatic build failure
>>> email.
>>> Weird, local tests are successful and that service doesn't seem to be
>>> related to my last commit... but I am looking into it.
>>>
>>> Jacopo
>>>
>>> On Tue, Sep 13, 2016 at 1:15 PM, Jacques Le Roux <
>>> jacques.le.roux@les7arts.com> wrote:
>>>
>>> You have got a small issue
>>>>
>>>> https://ci.apache.org/builders/ofbiz-trunk/builds/1415
>>>>
>>>> https://ci.apache.org/projects/ofbiz/logs/trunk/html/
>>>>
>>>> Jacques
>>>>
>>>>
>>>>
>>>> Le 13/09/2016 à 12:55, jacopoc@apache.org a écrit :
>>>>
>>>> Author: jacopoc
>>>>> Date: Tue Sep 13 10:55:12 2016
>>>>> New Revision: 1760528
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=1760528&view=rev
>>>>> Log:
>>>>> Improved: set the character encoding to the system default (UTF-8) if
>>>>> and
>>>>> only
>>>>> if it is not set already by the client.
>>>>>
>>>>> Before this change the filter used to override the character encoding,
>>>>> even if
>>>>> it was specified in the http request.
>>>>> Also removed some unused imports and comments.
>>>>>
>>>>>
>>>>> Modified:
>>>>> ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz
>>>>> /webapp/control/ContextFilter.java
>>>>>
>>>>> Modified: ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/
>>>>> webapp/control/ContextFilter.java
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/sr
>>>>> c/main/java/org/apache/ofbiz/webapp/control/ContextFilter.
>>>>> java?rev=1760528&r1=1760527&r2=1760528&view=diff
>>>>> ============================================================
>>>>> ==================
>>>>> --- ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/
>>>>> webapp/control/ContextFilter.java (original)
>>>>> +++ ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/
>>>>> webapp/control/ContextFilter.java Tue Sep 13 10:55:12 2016
>>>>> @@ -21,16 +21,13 @@ package org.apache.ofbiz.webapp.control;
>>>>>    import static org.apache.ofbiz.base.util.UtilGenerics.checkMap;
>>>>>      import java.io.IOException;
>>>>> -import java.io.UnsupportedEncodingException;
>>>>>    import java.util.Enumeration;
>>>>>    import java.util.List;
>>>>>    import java.util.Map;
>>>>> -import java.util.Set;
>>>>>      import javax.servlet.Filter;
>>>>>    import javax.servlet.FilterChain;
>>>>>    import javax.servlet.FilterConfig;
>>>>> -import javax.servlet.ServletContext;
>>>>>    import javax.servlet.ServletException;
>>>>>    import javax.servlet.ServletRequest;
>>>>>    import javax.servlet.ServletResponse;
>>>>> @@ -50,12 +47,8 @@ import org.apache.ofbiz.entity.GenericVa
>>>>>    import org.apache.ofbiz.entity.util.EntityQuery;
>>>>>    import org.apache.ofbiz.entity.util.EntityUtil;
>>>>>    import org.apache.ofbiz.security.Security;
>>>>> -import org.apache.ofbiz.security.SecurityConfigurationException;
>>>>> -import org.apache.ofbiz.security.SecurityFactory;
>>>>>    import org.apache.ofbiz.service.LocalDispatcher;
>>>>> -import org.apache.ofbiz.service.ServiceContainer;
>>>>>    import org.apache.ofbiz.webapp.WebAppUtil;
>>>>> -import org.apache.ofbiz.webapp.event.RequestBodyMapHandlerFactory;
>>>>>    import org.apache.ofbiz.webapp.website.WebSiteWorker;
>>>>>      /**
>>>>> @@ -69,6 +62,9 @@ public class ContextFilter implements Fi
>>>>>        protected FilterConfig config = null;
>>>>>        protected boolean debug = false;
>>>>>    +    // default charset used to decode requests body data if no
>>>>> encoding is specified in the request
>>>>> +    private String defaultCharacterEncoding;
>>>>> +
>>>>>        /**
>>>>>         * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
>>>>>         */
>>>>> @@ -84,6 +80,10 @@ public class ContextFilter implements Fi
>>>>>                debug = Debug.verboseOn();
>>>>>            }
>>>>>    +        defaultCharacterEncoding = config.getServletContext().get
>>>>> InitParameter("charset");
>>>>> +        if (UtilValidate.isEmpty(defaultCharacterEncoding)) {
>>>>> +            defaultCharacterEncoding = "UTF-8";
>>>>> +        }
>>>>>            // check the serverId
>>>>>            getServerId();
>>>>>            // initialize the delegator
>>>>> @@ -104,7 +104,6 @@ public class ContextFilter implements Fi
>>>>>            HttpServletRequest httpRequest = (HttpServletRequest)
>>>>> request;
>>>>>            HttpServletResponse httpResponse = (HttpServletResponse)
>>>>> response;
>>>>>    -        // Debug.logInfo("Running ContextFilter.doFilter", module);
>>>>>              // ----- Servlet Object Setup -----
>>>>>    @@ -250,10 +249,13 @@ public class ContextFilter implements Fi
>>>>>                }
>>>>>            }
>>>>>    +        if (request.getCharacterEncoding() == null) {
>>>>> + request.setCharacterEncoding(defaultCharacterEncoding);
>>>>> +        }
>>>>> +        WebAppUtil.setAttributesFromRequestBody(request);
>>>>> +
>>>>>            // check if multi tenant is enabled
>>>>>            boolean useMultitenant = EntityUtil.isMultiTenantEnabled();
>>>>> -        WebAppUtil.setCharacterEncoding(request);
>>>>> -        WebAppUtil.setAttributesFromRequestBody(request);
>>>>>            if (useMultitenant) {
>>>>>                // get tenant delegator by domain name
>>>>>                String serverName = httpRequest.getServerName();
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>
>>
>

Re: svn commit: r1760528 - /ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control /ContextFilter.java

Posted by Jacques Le Roux <ja...@les7arts.com>.
Tests passed, must have been a BuildBot quirk

https://ci.apache.org/builders/ofbiz-trunk/builds/1416

Jacques


Le 13/09/2016 � 14:48, Jacques Le Roux a �crit :
> Works also locally here, I have forced a new build on BuildBot, could be a temporary error, happens rarely but happens.
>
> Jacques
>
>
> Le 13/09/2016 � 13:43, Jacopo Cappellato a �crit :
>> Yeah, thanks for the notification, I also saw the automatic build failure
>> email.
>> Weird, local tests are successful and that service doesn't seem to be
>> related to my last commit... but I am looking into it.
>>
>> Jacopo
>>
>> On Tue, Sep 13, 2016 at 1:15 PM, Jacques Le Roux <
>> jacques.le.roux@les7arts.com> wrote:
>>
>>> You have got a small issue
>>>
>>> https://ci.apache.org/builders/ofbiz-trunk/builds/1415
>>>
>>> https://ci.apache.org/projects/ofbiz/logs/trunk/html/
>>>
>>> Jacques
>>>
>>>
>>>
>>> Le 13/09/2016 � 12:55, jacopoc@apache.org a �crit :
>>>
>>>> Author: jacopoc
>>>> Date: Tue Sep 13 10:55:12 2016
>>>> New Revision: 1760528
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=1760528&view=rev
>>>> Log:
>>>> Improved: set the character encoding to the system default (UTF-8) if and
>>>> only
>>>> if it is not set already by the client.
>>>>
>>>> Before this change the filter used to override the character encoding,
>>>> even if
>>>> it was specified in the http request.
>>>> Also removed some unused imports and comments.
>>>>
>>>>
>>>> Modified:
>>>> ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz
>>>> /webapp/control/ContextFilter.java
>>>>
>>>> Modified: ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/
>>>> webapp/control/ContextFilter.java
>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/sr
>>>> c/main/java/org/apache/ofbiz/webapp/control/ContextFilter.
>>>> java?rev=1760528&r1=1760527&r2=1760528&view=diff
>>>> ============================================================
>>>> ==================
>>>> --- ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/
>>>> webapp/control/ContextFilter.java (original)
>>>> +++ ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/
>>>> webapp/control/ContextFilter.java Tue Sep 13 10:55:12 2016
>>>> @@ -21,16 +21,13 @@ package org.apache.ofbiz.webapp.control;
>>>>    import static org.apache.ofbiz.base.util.UtilGenerics.checkMap;
>>>>      import java.io.IOException;
>>>> -import java.io.UnsupportedEncodingException;
>>>>    import java.util.Enumeration;
>>>>    import java.util.List;
>>>>    import java.util.Map;
>>>> -import java.util.Set;
>>>>      import javax.servlet.Filter;
>>>>    import javax.servlet.FilterChain;
>>>>    import javax.servlet.FilterConfig;
>>>> -import javax.servlet.ServletContext;
>>>>    import javax.servlet.ServletException;
>>>>    import javax.servlet.ServletRequest;
>>>>    import javax.servlet.ServletResponse;
>>>> @@ -50,12 +47,8 @@ import org.apache.ofbiz.entity.GenericVa
>>>>    import org.apache.ofbiz.entity.util.EntityQuery;
>>>>    import org.apache.ofbiz.entity.util.EntityUtil;
>>>>    import org.apache.ofbiz.security.Security;
>>>> -import org.apache.ofbiz.security.SecurityConfigurationException;
>>>> -import org.apache.ofbiz.security.SecurityFactory;
>>>>    import org.apache.ofbiz.service.LocalDispatcher;
>>>> -import org.apache.ofbiz.service.ServiceContainer;
>>>>    import org.apache.ofbiz.webapp.WebAppUtil;
>>>> -import org.apache.ofbiz.webapp.event.RequestBodyMapHandlerFactory;
>>>>    import org.apache.ofbiz.webapp.website.WebSiteWorker;
>>>>      /**
>>>> @@ -69,6 +62,9 @@ public class ContextFilter implements Fi
>>>>        protected FilterConfig config = null;
>>>>        protected boolean debug = false;
>>>>    +    // default charset used to decode requests body data if no
>>>> encoding is specified in the request
>>>> +    private String defaultCharacterEncoding;
>>>> +
>>>>        /**
>>>>         * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
>>>>         */
>>>> @@ -84,6 +80,10 @@ public class ContextFilter implements Fi
>>>>                debug = Debug.verboseOn();
>>>>            }
>>>>    +        defaultCharacterEncoding = config.getServletContext().get
>>>> InitParameter("charset");
>>>> +        if (UtilValidate.isEmpty(defaultCharacterEncoding)) {
>>>> +            defaultCharacterEncoding = "UTF-8";
>>>> +        }
>>>>            // check the serverId
>>>>            getServerId();
>>>>            // initialize the delegator
>>>> @@ -104,7 +104,6 @@ public class ContextFilter implements Fi
>>>>            HttpServletRequest httpRequest = (HttpServletRequest) request;
>>>>            HttpServletResponse httpResponse = (HttpServletResponse)
>>>> response;
>>>>    -        // Debug.logInfo("Running ContextFilter.doFilter", module);
>>>>              // ----- Servlet Object Setup -----
>>>>    @@ -250,10 +249,13 @@ public class ContextFilter implements Fi
>>>>                }
>>>>            }
>>>>    +        if (request.getCharacterEncoding() == null) {
>>>> + request.setCharacterEncoding(defaultCharacterEncoding);
>>>> +        }
>>>> +        WebAppUtil.setAttributesFromRequestBody(request);
>>>> +
>>>>            // check if multi tenant is enabled
>>>>            boolean useMultitenant = EntityUtil.isMultiTenantEnabled();
>>>> -        WebAppUtil.setCharacterEncoding(request);
>>>> -        WebAppUtil.setAttributesFromRequestBody(request);
>>>>            if (useMultitenant) {
>>>>                // get tenant delegator by domain name
>>>>                String serverName = httpRequest.getServerName();
>>>>
>>>>
>>>>
>>>>
>
>


Re: svn commit: r1760528 - /ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control /ContextFilter.java

Posted by Jacques Le Roux <ja...@les7arts.com>.
Works also locally here, I have forced a new build on BuildBot, could be a temporary error, happens rarely but happens.

Jacques


Le 13/09/2016 � 13:43, Jacopo Cappellato a �crit :
> Yeah, thanks for the notification, I also saw the automatic build failure
> email.
> Weird, local tests are successful and that service doesn't seem to be
> related to my last commit... but I am looking into it.
>
> Jacopo
>
> On Tue, Sep 13, 2016 at 1:15 PM, Jacques Le Roux <
> jacques.le.roux@les7arts.com> wrote:
>
>> You have got a small issue
>>
>> https://ci.apache.org/builders/ofbiz-trunk/builds/1415
>>
>> https://ci.apache.org/projects/ofbiz/logs/trunk/html/
>>
>> Jacques
>>
>>
>>
>> Le 13/09/2016 � 12:55, jacopoc@apache.org a �crit :
>>
>>> Author: jacopoc
>>> Date: Tue Sep 13 10:55:12 2016
>>> New Revision: 1760528
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1760528&view=rev
>>> Log:
>>> Improved: set the character encoding to the system default (UTF-8) if and
>>> only
>>> if it is not set already by the client.
>>>
>>> Before this change the filter used to override the character encoding,
>>> even if
>>> it was specified in the http request.
>>> Also removed some unused imports and comments.
>>>
>>>
>>> Modified:
>>>       ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz
>>> /webapp/control/ContextFilter.java
>>>
>>> Modified: ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/
>>> webapp/control/ContextFilter.java
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/sr
>>> c/main/java/org/apache/ofbiz/webapp/control/ContextFilter.
>>> java?rev=1760528&r1=1760527&r2=1760528&view=diff
>>> ============================================================
>>> ==================
>>> --- ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/
>>> webapp/control/ContextFilter.java (original)
>>> +++ ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/
>>> webapp/control/ContextFilter.java Tue Sep 13 10:55:12 2016
>>> @@ -21,16 +21,13 @@ package org.apache.ofbiz.webapp.control;
>>>    import static org.apache.ofbiz.base.util.UtilGenerics.checkMap;
>>>      import java.io.IOException;
>>> -import java.io.UnsupportedEncodingException;
>>>    import java.util.Enumeration;
>>>    import java.util.List;
>>>    import java.util.Map;
>>> -import java.util.Set;
>>>      import javax.servlet.Filter;
>>>    import javax.servlet.FilterChain;
>>>    import javax.servlet.FilterConfig;
>>> -import javax.servlet.ServletContext;
>>>    import javax.servlet.ServletException;
>>>    import javax.servlet.ServletRequest;
>>>    import javax.servlet.ServletResponse;
>>> @@ -50,12 +47,8 @@ import org.apache.ofbiz.entity.GenericVa
>>>    import org.apache.ofbiz.entity.util.EntityQuery;
>>>    import org.apache.ofbiz.entity.util.EntityUtil;
>>>    import org.apache.ofbiz.security.Security;
>>> -import org.apache.ofbiz.security.SecurityConfigurationException;
>>> -import org.apache.ofbiz.security.SecurityFactory;
>>>    import org.apache.ofbiz.service.LocalDispatcher;
>>> -import org.apache.ofbiz.service.ServiceContainer;
>>>    import org.apache.ofbiz.webapp.WebAppUtil;
>>> -import org.apache.ofbiz.webapp.event.RequestBodyMapHandlerFactory;
>>>    import org.apache.ofbiz.webapp.website.WebSiteWorker;
>>>      /**
>>> @@ -69,6 +62,9 @@ public class ContextFilter implements Fi
>>>        protected FilterConfig config = null;
>>>        protected boolean debug = false;
>>>    +    // default charset used to decode requests body data if no
>>> encoding is specified in the request
>>> +    private String defaultCharacterEncoding;
>>> +
>>>        /**
>>>         * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
>>>         */
>>> @@ -84,6 +80,10 @@ public class ContextFilter implements Fi
>>>                debug = Debug.verboseOn();
>>>            }
>>>    +        defaultCharacterEncoding = config.getServletContext().get
>>> InitParameter("charset");
>>> +        if (UtilValidate.isEmpty(defaultCharacterEncoding)) {
>>> +            defaultCharacterEncoding = "UTF-8";
>>> +        }
>>>            // check the serverId
>>>            getServerId();
>>>            // initialize the delegator
>>> @@ -104,7 +104,6 @@ public class ContextFilter implements Fi
>>>            HttpServletRequest httpRequest = (HttpServletRequest) request;
>>>            HttpServletResponse httpResponse = (HttpServletResponse)
>>> response;
>>>    -        // Debug.logInfo("Running ContextFilter.doFilter", module);
>>>              // ----- Servlet Object Setup -----
>>>    @@ -250,10 +249,13 @@ public class ContextFilter implements Fi
>>>                }
>>>            }
>>>    +        if (request.getCharacterEncoding() == null) {
>>> +            request.setCharacterEncoding(defaultCharacterEncoding);
>>> +        }
>>> +        WebAppUtil.setAttributesFromRequestBody(request);
>>> +
>>>            // check if multi tenant is enabled
>>>            boolean useMultitenant = EntityUtil.isMultiTenantEnabled();
>>> -        WebAppUtil.setCharacterEncoding(request);
>>> -        WebAppUtil.setAttributesFromRequestBody(request);
>>>            if (useMultitenant) {
>>>                // get tenant delegator by domain name
>>>                String serverName = httpRequest.getServerName();
>>>
>>>
>>>
>>>


Re: svn commit: r1760528 - /ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control /ContextFilter.java

Posted by Jacopo Cappellato <ja...@hotwaxsystems.com>.
Yeah, thanks for the notification, I also saw the automatic build failure
email.
Weird, local tests are successful and that service doesn't seem to be
related to my last commit... but I am looking into it.

Jacopo

On Tue, Sep 13, 2016 at 1:15 PM, Jacques Le Roux <
jacques.le.roux@les7arts.com> wrote:

> You have got a small issue
>
> https://ci.apache.org/builders/ofbiz-trunk/builds/1415
>
> https://ci.apache.org/projects/ofbiz/logs/trunk/html/
>
> Jacques
>
>
>
> Le 13/09/2016 à 12:55, jacopoc@apache.org a écrit :
>
>> Author: jacopoc
>> Date: Tue Sep 13 10:55:12 2016
>> New Revision: 1760528
>>
>> URL: http://svn.apache.org/viewvc?rev=1760528&view=rev
>> Log:
>> Improved: set the character encoding to the system default (UTF-8) if and
>> only
>> if it is not set already by the client.
>>
>> Before this change the filter used to override the character encoding,
>> even if
>> it was specified in the http request.
>> Also removed some unused imports and comments.
>>
>>
>> Modified:
>>      ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz
>> /webapp/control/ContextFilter.java
>>
>> Modified: ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/
>> webapp/control/ContextFilter.java
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/sr
>> c/main/java/org/apache/ofbiz/webapp/control/ContextFilter.
>> java?rev=1760528&r1=1760527&r2=1760528&view=diff
>> ============================================================
>> ==================
>> --- ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/
>> webapp/control/ContextFilter.java (original)
>> +++ ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/
>> webapp/control/ContextFilter.java Tue Sep 13 10:55:12 2016
>> @@ -21,16 +21,13 @@ package org.apache.ofbiz.webapp.control;
>>   import static org.apache.ofbiz.base.util.UtilGenerics.checkMap;
>>     import java.io.IOException;
>> -import java.io.UnsupportedEncodingException;
>>   import java.util.Enumeration;
>>   import java.util.List;
>>   import java.util.Map;
>> -import java.util.Set;
>>     import javax.servlet.Filter;
>>   import javax.servlet.FilterChain;
>>   import javax.servlet.FilterConfig;
>> -import javax.servlet.ServletContext;
>>   import javax.servlet.ServletException;
>>   import javax.servlet.ServletRequest;
>>   import javax.servlet.ServletResponse;
>> @@ -50,12 +47,8 @@ import org.apache.ofbiz.entity.GenericVa
>>   import org.apache.ofbiz.entity.util.EntityQuery;
>>   import org.apache.ofbiz.entity.util.EntityUtil;
>>   import org.apache.ofbiz.security.Security;
>> -import org.apache.ofbiz.security.SecurityConfigurationException;
>> -import org.apache.ofbiz.security.SecurityFactory;
>>   import org.apache.ofbiz.service.LocalDispatcher;
>> -import org.apache.ofbiz.service.ServiceContainer;
>>   import org.apache.ofbiz.webapp.WebAppUtil;
>> -import org.apache.ofbiz.webapp.event.RequestBodyMapHandlerFactory;
>>   import org.apache.ofbiz.webapp.website.WebSiteWorker;
>>     /**
>> @@ -69,6 +62,9 @@ public class ContextFilter implements Fi
>>       protected FilterConfig config = null;
>>       protected boolean debug = false;
>>   +    // default charset used to decode requests body data if no
>> encoding is specified in the request
>> +    private String defaultCharacterEncoding;
>> +
>>       /**
>>        * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
>>        */
>> @@ -84,6 +80,10 @@ public class ContextFilter implements Fi
>>               debug = Debug.verboseOn();
>>           }
>>   +        defaultCharacterEncoding = config.getServletContext().get
>> InitParameter("charset");
>> +        if (UtilValidate.isEmpty(defaultCharacterEncoding)) {
>> +            defaultCharacterEncoding = "UTF-8";
>> +        }
>>           // check the serverId
>>           getServerId();
>>           // initialize the delegator
>> @@ -104,7 +104,6 @@ public class ContextFilter implements Fi
>>           HttpServletRequest httpRequest = (HttpServletRequest) request;
>>           HttpServletResponse httpResponse = (HttpServletResponse)
>> response;
>>   -        // Debug.logInfo("Running ContextFilter.doFilter", module);
>>             // ----- Servlet Object Setup -----
>>   @@ -250,10 +249,13 @@ public class ContextFilter implements Fi
>>               }
>>           }
>>   +        if (request.getCharacterEncoding() == null) {
>> +            request.setCharacterEncoding(defaultCharacterEncoding);
>> +        }
>> +        WebAppUtil.setAttributesFromRequestBody(request);
>> +
>>           // check if multi tenant is enabled
>>           boolean useMultitenant = EntityUtil.isMultiTenantEnabled();
>> -        WebAppUtil.setCharacterEncoding(request);
>> -        WebAppUtil.setAttributesFromRequestBody(request);
>>           if (useMultitenant) {
>>               // get tenant delegator by domain name
>>               String serverName = httpRequest.getServerName();
>>
>>
>>
>>
>

Re: svn commit: r1760528 - /ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control /ContextFilter.java

Posted by Jacques Le Roux <ja...@les7arts.com>.
You have got a small issue

https://ci.apache.org/builders/ofbiz-trunk/builds/1415

https://ci.apache.org/projects/ofbiz/logs/trunk/html/

Jacques


Le 13/09/2016 � 12:55, jacopoc@apache.org a �crit :
> Author: jacopoc
> Date: Tue Sep 13 10:55:12 2016
> New Revision: 1760528
>
> URL: http://svn.apache.org/viewvc?rev=1760528&view=rev
> Log:
> Improved: set the character encoding to the system default (UTF-8) if and only
> if it is not set already by the client.
>
> Before this change the filter used to override the character encoding, even if
> it was specified in the http request.
> Also removed some unused imports and comments.
>
>
> Modified:
>      ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java
>
> Modified: ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java?rev=1760528&r1=1760527&r2=1760528&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java (original)
> +++ ofbiz/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ContextFilter.java Tue Sep 13 10:55:12 2016
> @@ -21,16 +21,13 @@ package org.apache.ofbiz.webapp.control;
>   import static org.apache.ofbiz.base.util.UtilGenerics.checkMap;
>   
>   import java.io.IOException;
> -import java.io.UnsupportedEncodingException;
>   import java.util.Enumeration;
>   import java.util.List;
>   import java.util.Map;
> -import java.util.Set;
>   
>   import javax.servlet.Filter;
>   import javax.servlet.FilterChain;
>   import javax.servlet.FilterConfig;
> -import javax.servlet.ServletContext;
>   import javax.servlet.ServletException;
>   import javax.servlet.ServletRequest;
>   import javax.servlet.ServletResponse;
> @@ -50,12 +47,8 @@ import org.apache.ofbiz.entity.GenericVa
>   import org.apache.ofbiz.entity.util.EntityQuery;
>   import org.apache.ofbiz.entity.util.EntityUtil;
>   import org.apache.ofbiz.security.Security;
> -import org.apache.ofbiz.security.SecurityConfigurationException;
> -import org.apache.ofbiz.security.SecurityFactory;
>   import org.apache.ofbiz.service.LocalDispatcher;
> -import org.apache.ofbiz.service.ServiceContainer;
>   import org.apache.ofbiz.webapp.WebAppUtil;
> -import org.apache.ofbiz.webapp.event.RequestBodyMapHandlerFactory;
>   import org.apache.ofbiz.webapp.website.WebSiteWorker;
>   
>   /**
> @@ -69,6 +62,9 @@ public class ContextFilter implements Fi
>       protected FilterConfig config = null;
>       protected boolean debug = false;
>   
> +    // default charset used to decode requests body data if no encoding is specified in the request
> +    private String defaultCharacterEncoding;
> +
>       /**
>        * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
>        */
> @@ -84,6 +80,10 @@ public class ContextFilter implements Fi
>               debug = Debug.verboseOn();
>           }
>   
> +        defaultCharacterEncoding = config.getServletContext().getInitParameter("charset");
> +        if (UtilValidate.isEmpty(defaultCharacterEncoding)) {
> +            defaultCharacterEncoding = "UTF-8";
> +        }
>           // check the serverId
>           getServerId();
>           // initialize the delegator
> @@ -104,7 +104,6 @@ public class ContextFilter implements Fi
>           HttpServletRequest httpRequest = (HttpServletRequest) request;
>           HttpServletResponse httpResponse = (HttpServletResponse) response;
>   
> -        // Debug.logInfo("Running ContextFilter.doFilter", module);
>   
>           // ----- Servlet Object Setup -----
>   
> @@ -250,10 +249,13 @@ public class ContextFilter implements Fi
>               }
>           }
>   
> +        if (request.getCharacterEncoding() == null) {
> +            request.setCharacterEncoding(defaultCharacterEncoding);
> +        }
> +        WebAppUtil.setAttributesFromRequestBody(request);
> +
>           // check if multi tenant is enabled
>           boolean useMultitenant = EntityUtil.isMultiTenantEnabled();
> -        WebAppUtil.setCharacterEncoding(request);
> -        WebAppUtil.setAttributesFromRequestBody(request);
>           if (useMultitenant) {
>               // get tenant delegator by domain name
>               String serverName = httpRequest.getServerName();
>
>
>