You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by Florent Guillaume <fg...@nuxeo.com> on 2010/04/01 18:58:41 UTC

Re: svn commit: r927159 - /incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/AtomPubUtils.java

I really don't think this is a good idea. The parameters are defined
by the spec and you should be strict about them.

Florent

On Wed, Mar 24, 2010 at 8:14 PM, fmui <fm...@apache.org> wrote:
> Author: fmui
> Date: Wed Mar 24 19:14:47 2010
> New Revision: 927159
>
> URL: http://svn.apache.org/viewvc?rev=927159&view=rev
> Log:
> made parameter recognition case-insensitive in AtomPub server
>
> Modified:
>    incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/AtomPubUtils.java
>
> Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/AtomPubUtils.java
> URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/AtomPubUtils.java?rev=927159&r1=927158&r2=927159&view=diff
> ==============================================================================
> --- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/AtomPubUtils.java (original)
> +++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/AtomPubUtils.java Wed Mar 24 19:14:47 2010
> @@ -128,15 +128,30 @@ public final class AtomPubUtils {
>   /**
>    * Extracts a string parameter.
>    */
> +  @SuppressWarnings("unchecked")
>   public static String getStringParameter(HttpServletRequest request, String name) {
> -    return request.getParameter(name);
> +    if (name == null) {
> +      return null;
> +    }
> +
> +    Map<String, String[]> parameters = (Map<String, String[]>) request.getParameterMap();
> +    for (Map.Entry<String, String[]> parameter : parameters.entrySet()) {
> +      if (name.equalsIgnoreCase(parameter.getKey())) {
> +        if (parameter.getValue() == null) {
> +          return null;
> +        }
> +        return parameter.getValue()[0];
> +      }
> +    }
> +
> +    return null;
>   }
>
>   /**
>    * Extracts a boolean parameter (with default).
>    */
>   public static boolean getBooleanParameter(HttpServletRequest request, String name, boolean def) {
> -    String value = request.getParameter(name);
> +    String value = getStringParameter(request, name);
>     if (value == null) {
>       return def;
>     }
> @@ -148,7 +163,7 @@ public final class AtomPubUtils {
>    * Extracts a boolean parameter.
>    */
>   public static Boolean getBooleanParameter(HttpServletRequest request, String name) {
> -    String value = request.getParameter(name);
> +    String value = getStringParameter(request, name);
>     if (value == null) {
>       return null;
>     }
> @@ -172,7 +187,7 @@ public final class AtomPubUtils {
>    * Extracts an integer parameter.
>    */
>   public static BigInteger getBigIntegerParameter(HttpServletRequest request, String name) {
> -    String value = request.getParameter(name);
> +    String value = getStringParameter(request, name);
>     if (value == null) {
>       return null;
>     }
> @@ -190,7 +205,7 @@ public final class AtomPubUtils {
>    */
>   @SuppressWarnings("unchecked")
>   public static <T> T getEnumParameter(HttpServletRequest request, String name, Class<T> clazz) {
> -    String value = request.getParameter(name);
> +    String value = getStringParameter(request, name);
>     if (value == null) {
>       return null;
>     }
>
>
>



-- 
Florent Guillaume, Director of R&D, Nuxeo
Open Source, Java EE based, Enterprise Content Management (ECM)
http://www.nuxeo.com   http://www.nuxeo.org   +33 1 40 33 79 87