Author: dolander
Date: Tue Dec 14 14:03:29 2004
New Revision: 111885

URL: http://svn.apache.org/viewcvs?view=rev&rev=111885
Log:
Contributor: Brian Che

This is a modification of the contribution from Brian Che that switched to 
using the 
commons-codec URLCodec from the java.net.URLEncoder/Decoder.

Instead of introducing a new model and .jar file into netui, I backed out the 
changes to the
scoping module to avoid the circular dependency and put the code into the 
util.jar.  

I did this, so that the code could eventual be moved into a beehive common .jar 
file (which doesn't currently exist).  In the mean time, I will assign the 
issue 
to Rich to resolve some issues with Scoping and why it proceeds the util.jar.
We need to resolve how these need two jars releate to each other and with an 
eventual 
common jar file for all of beehive.



Added:
   incubator/beehive/trunk/external/commons-codec/
   incubator/beehive/trunk/external/commons-codec/commons-codec-1.3.jar
      - copied unchanged from r111512, 
incubator/beehive/trunk/wsm/external/commons-codec-1.3.jar
   
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/URLCodec.java
Removed:
   incubator/beehive/trunk/wsm/external/commons-codec-1.3.jar
Modified:
   incubator/beehive/trunk/beehive.properties
   incubator/beehive/trunk/build.xml
   incubator/beehive/trunk/netui/ant/webappTemplate.xml
   
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/HtmlUtils.java
   
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java
   incubator/beehive/trunk/netui/src/util/build.xml
   
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java
   incubator/beehive/trunk/netui/test/ant/junitCore.xml
   incubator/beehive/trunk/wsm/build.xml
   incubator/beehive/trunk/wsm/drt/build.xml

Modified: incubator/beehive/trunk/beehive.properties
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/beehive.properties?view=diff&rev=111885&p1=incubator/beehive/trunk/beehive.properties&r1=111884&p2=incubator/beehive/trunk/beehive.properties&r2=111885
==============================================================================
--- incubator/beehive/trunk/beehive.properties  (original)
+++ incubator/beehive/trunk/beehive.properties  Tue Dec 14 14:03:29 2004
@@ -42,6 +42,7 @@
 # that are installed in the build (or by Maven) from
 # the various installers.
 #
+commons-codec.jar=${beehive.external.dir}/commons-codec/commons-codec-1.3.jar
 log4j.jar=${beehive.external.dir}/log4j/log4j-1.2.8.jar
 servlet24.jar=${beehive.external.dir}/servlet/servlet-api-2.4.jar
 jsp20.jar=${beehive.external.dir}/servlet/jsp-api-2.0.jar

Modified: incubator/beehive/trunk/build.xml
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/build.xml?view=diff&rev=111885&p1=incubator/beehive/trunk/build.xml&r1=111884&p2=incubator/beehive/trunk/build.xml&r2=111885
==============================================================================
--- incubator/beehive/trunk/build.xml   (original)
+++ incubator/beehive/trunk/build.xml   Tue Dec 14 14:03:29 2004
@@ -234,6 +234,7 @@
     <target name="build.dist.core">
         <!-- copy the required libraries into dist/ -->
         <copy todir="${dist.dir}/lib/common" failOnError="true">
+            <fileset file="${commons-codec.jar}"/>
             <fileset file="${log4j.jar}"/>
             <fileset file="${xbean.jar}"/>
             <fileset file="${jsr173.jar}"/>

Copied: incubator/beehive/trunk/external/commons-codec/commons-codec-1.3.jar 
(from r111512, incubator/beehive/trunk/wsm/external/commons-codec-1.3.jar)
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/external/commons-codec/commons-codec-1.3.jar?view=diff&rev=111885&p1=incubator/beehive/trunk/wsm/external/commons-codec-1.3.jar&r1=111512&p2=incubator/beehive/trunk/external/commons-codec/commons-codec-1.3.jar&r2=111885
==============================================================================

Modified: incubator/beehive/trunk/netui/ant/webappTemplate.xml
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/ant/webappTemplate.xml?view=diff&rev=111885&p1=incubator/beehive/trunk/netui/ant/webappTemplate.xml&r1=111884&p2=incubator/beehive/trunk/netui/ant/webappTemplate.xml&r2=111885
==============================================================================
--- incubator/beehive/trunk/netui/ant/webappTemplate.xml        (original)
+++ incubator/beehive/trunk/netui/ant/webappTemplate.xml        Tue Dec 14 
14:03:29 2004
@@ -48,6 +48,7 @@
         <copy todir="${webinf.lib}" file="${xbean.jar}"/>
         <copy todir="${webinf.lib}" file="${jsr173.jar}"/>
         <copy todir="${webinf.lib}" file="${log4j.jar}"/>
+        <copy todir="${webinf.lib}" file="${commons-codec.jar}"/>
 
         <!-- copy the Beehive JARs -->
         <copy todir="${webinf.lib}" file="${controls.jar}"/>
@@ -114,6 +115,7 @@
             they are copied directly into WEB-INF/lib of the webapp template.
           -->
         <copy todir="${webapp.dir}/WEB-INF/lib" file="${log4j.jar}"/>
+        <copy todir="${webapp.dir}/WEB-INF/lib" file="${commons-codec.jar}"/>
         <copy todir="${webapp.dir}/WEB-INF/lib" file="${controls.jar}"/>
         <copy todir="${webapp.dir}/WEB-INF/lib" file="${jsr173.jar}"/>
         <copy todir="${webapp.dir}/WEB-INF/lib" file="${xbean.jar}"/>

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/HtmlUtils.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/HtmlUtils.java?view=diff&rev=111885&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/HtmlUtils.java&r1=111884&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/HtmlUtils.java&r2=111885
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/HtmlUtils.java
    (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/HtmlUtils.java
    Tue Dec 14 14:03:29 2004
@@ -20,10 +20,10 @@
 import org.apache.beehive.netui.util.config.ConfigUtil;
 import org.apache.beehive.netui.util.config.bean.NetuiConfigDocument;
 import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender;
+import org.apache.beehive.netui.core.URLCodec;
 
 import javax.servlet.jsp.JspException;
 import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
 import java.util.Iterator;
 import java.util.Map;
 
@@ -159,7 +159,7 @@
                         else {
                             urlBuffer.append("&");
                         }
-                        urlBuffer.append(URLEncoder.encode(key, encoding));
+                        urlBuffer.append(URLCodec.encode(key, encoding));
                         urlBuffer.append('='); // Interpret null as "no value"
                     }
                     else if (value instanceof String) {
@@ -170,9 +170,9 @@
                         else {
                             urlBuffer.append("&");
                         }
-                        urlBuffer.append(URLEncoder.encode(key, encoding));
+                        urlBuffer.append(URLCodec.encode(key, encoding));
                         urlBuffer.append('=');
-                        urlBuffer.append(URLEncoder.encode((String) value, 
encoding));
+                        urlBuffer.append(URLCodec.encode((String) value, 
encoding));
                     }
                     else if (value instanceof String[]) {
                         String values[] = (String[]) value;
@@ -184,9 +184,9 @@
                             else {
                                 urlBuffer.append("&");
                             }
-                            urlBuffer.append(URLEncoder.encode(key, encoding));
+                            urlBuffer.append(URLCodec.encode(key, encoding));
                             urlBuffer.append('=');
-                            urlBuffer.append(URLEncoder.encode(values[i], 
encoding));
+                            urlBuffer.append(URLCodec.encode(values[i], 
encoding));
                         }
                     }
                     else /* Convert other objects to a string */ {
@@ -197,9 +197,9 @@
                         else {
                             urlBuffer.append("&");
                         }
-                        urlBuffer.append(URLEncoder.encode(key, encoding));
+                        urlBuffer.append(URLCodec.encode(key, encoding));
                         urlBuffer.append('=');
-                        urlBuffer.append(URLEncoder.encode(value.toString(),
+                        urlBuffer.append(URLCodec.encode(value.toString(),
                                 encoding));
                     }
                 }

Modified: 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java?view=diff&rev=111885&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java&r1=111884&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java&r2=111885
==============================================================================
--- 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java
    (original)
+++ 
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java
    Tue Dec 14 14:03:29 2004
@@ -29,6 +29,7 @@
 import org.apache.beehive.netui.tags.internal.PageFlowTagUtils;
 import org.apache.beehive.netui.tags.rendering.*;
 import org.apache.beehive.netui.util.Bundle;
+import org.apache.beehive.netui.core.URLCodec;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -37,7 +38,6 @@
 import javax.servlet.ServletContext;
 import java.io.IOException;
 import java.net.URISyntaxException;
-import java.net.URLEncoder;
 import java.util.HashMap;
 
 
@@ -697,7 +697,7 @@
         // character in parameter values.
         String encodedNodeName = null;
         try {
-            encodedNodeName = URLEncoder.encode(nodeName, encoding);
+            encodedNodeName = URLCodec.encode(nodeName, encoding);
             assert(encodedNodeName != null);
         }
         catch (IOException e) {

Modified: incubator/beehive/trunk/netui/src/util/build.xml
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/build.xml?view=diff&rev=111885&p1=incubator/beehive/trunk/netui/src/util/build.xml&r1=111884&p2=incubator/beehive/trunk/netui/src/util/build.xml&r2=111885
==============================================================================
--- incubator/beehive/trunk/netui/src/util/build.xml    (original)
+++ incubator/beehive/trunk/netui/src/util/build.xml    Tue Dec 14 14:03:29 2004
@@ -19,6 +19,7 @@
         <pathelement path="${xbean.jar}"/>
         <pathelement path="${jsr173.jar}"/>
         <pathelement path="${scoping.jar}"/>
+        <pathelement path="${commons-codec.jar}"/>
     </path>
 
     <target name="build">

Added: 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/URLCodec.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/URLCodec.java?view=auto&rev=111885
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/URLCodec.java
  Tue Dec 14 14:03:29 2004
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+
+package org.apache.beehive.netui.core;
+
+import org.apache.commons.codec.EncoderException;
+import org.apache.commons.codec.DecoderException;
+
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Class that provides static methods for URL encoding/decoding
+ */
+public final class URLCodec {
+    private final static org.apache.commons.codec.net.URLCodec s_codec =
+        new org.apache.commons.codec.net.URLCodec();
+
+    /**
+     * URL encodes a string.
+     * @param decoded the string to encode
+     * @param charset the character set to use
+     * @return the encoded string
+     */
+    public static String encode(final String decoded, final String charset) 
+        throws UnsupportedEncodingException {
+        return s_codec.encode(decoded, charset);
+    }
+
+    /**
+     * URL encodes a string using the default character set
+     * @param decoded the string to encode
+     * @return the encoded string
+     */
+    public static String encode(final String decoded) {
+        try {
+            return s_codec.encode(decoded);
+        } catch (EncoderException e) {
+            throw new IllegalStateException(e.getMessage());
+        }
+    }
+
+    /**
+     * URL decodes a string.
+     * @param encoded the string to decode
+     * @param charset the character set to use
+     * @return the decoded string
+     */
+    public static String decode(final String encoded, final String charset) 
+        throws UnsupportedEncodingException {
+        try {
+            return s_codec.decode(encoded, charset);
+        } catch (DecoderException e) {
+            throw new IllegalStateException(e.getMessage());
+        } 
+    }
+
+
+    /**
+     * URL decodes a string using the default character set
+     * @param encoded the string to decode
+     * @return the decoded string
+     */
+    public static String decode(final String encoded) {
+        try {
+            return s_codec.decode(encoded);
+        } catch (DecoderException e) {
+            throw new IllegalStateException(e.getMessage());
+        }
+    }
+}

Modified: 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java?view=diff&rev=111885&p1=incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java&r1=111884&p2=incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java&r2=111885
==============================================================================
--- 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java
   (original)
+++ 
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java
   Tue Dec 14 14:03:29 2004
@@ -17,10 +17,11 @@
  */
 package org.apache.beehive.netui.core.urls;
 
+import org.apache.beehive.netui.core.URLCodec;
+
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
@@ -828,14 +829,14 @@
         String encodedURL = null;
         try
         {
-            encodedURL = URLEncoder.encode( url, encoding );
+            encodedURL = URLCodec.encode( url, encoding );
         }
         catch ( java.io.UnsupportedEncodingException e )
         {
             // try utf-8 as a default encoding
             try
             {
-                encodedURL = URLEncoder.encode( url, DEFAULT_ENCODING );
+                encodedURL = URLCodec.encode( url, DEFAULT_ENCODING );
             }
             catch ( java.io.UnsupportedEncodingException ignore )
             {

Modified: incubator/beehive/trunk/netui/test/ant/junitCore.xml
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/ant/junitCore.xml?view=diff&rev=111885&p1=incubator/beehive/trunk/netui/test/ant/junitCore.xml&r1=111884&p2=incubator/beehive/trunk/netui/test/ant/junitCore.xml&r2=111885
==============================================================================
--- incubator/beehive/trunk/netui/test/ant/junitCore.xml        (original)
+++ incubator/beehive/trunk/netui/test/ant/junitCore.xml        Tue Dec 14 
14:03:29 2004
@@ -13,6 +13,7 @@
         <pathelement path="${junit.jar}"/>
         <pathelement path="${servlet24.jar}"/>
         <pathelement path="${jsp20.jar}"/>
+        <pathelement path="${commons-codec.jar}"/>
     </path>
 
     <target name="run.tests">

Modified: incubator/beehive/trunk/wsm/build.xml
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/build.xml?view=diff&rev=111885&p1=incubator/beehive/trunk/wsm/build.xml&r1=111884&p2=incubator/beehive/trunk/wsm/build.xml&r2=111885
==============================================================================
--- incubator/beehive/trunk/wsm/build.xml       (original)
+++ incubator/beehive/trunk/wsm/build.xml       Tue Dec 14 14:03:29 2004
@@ -49,6 +49,7 @@
         <pathelement location="${log4j.jar}"/>
         <pathelement location="${lib.dir}/wsdltypes.jar"/>
         <pathelement location="${lib.dir}/schematypes.jar"/>
+        <pathelement location="${commons-codec.jar}"/>
        <pathelement location="${velocity14.jar}"/>
        <pathelement location="${velocitydep14.jar}"/> 
     </path>
@@ -58,7 +59,6 @@
         <include name="jaxrpc.jar"/>
         <include name="commons-logging.jar"/>
         <include name="commons-discovery.jar"/>
-        <include name="commons-codec-1.3.jar"/>
         <include name="axis-ant.jar"/>
         <include name="axis.jar"/>
     </fileset>

Modified: incubator/beehive/trunk/wsm/drt/build.xml
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/drt/build.xml?view=diff&rev=111885&p1=incubator/beehive/trunk/wsm/drt/build.xml&r1=111884&p2=incubator/beehive/trunk/wsm/drt/build.xml&r2=111885
==============================================================================
--- incubator/beehive/trunk/wsm/drt/build.xml   (original)
+++ incubator/beehive/trunk/wsm/drt/build.xml   Tue Dec 14 14:03:29 2004
@@ -44,7 +44,6 @@
         <include name="jaxrpc.jar"/>
         <include name="commons-logging.jar"/>
         <include name="commons-discovery.jar"/>
-        <include name="commons-codec-1.3.jar"/>
         <include name="axis-ant.jar"/>
         <include name="axis.jar"/>
     </fileset>
@@ -53,6 +52,7 @@
         <pathelement location="${tools.jar}"/>
         <pathelement location="${xbean.jar}"/>
         <pathelement location="${jsr173.jar}"/>
+        <pathelement location="${commons-codec.jar}"/>
         <pathelement location="${log4j.jar}"/>
         <pathelement location="${lib.dir}/wsdltypes.jar"/>
         <pathelement location="${lib.dir}/schematypes.jar"/>

Deleted: /incubator/beehive/trunk/wsm/external/commons-codec-1.3.jar
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/external/commons-codec-1.3.jar?view=auto&rev=111884
==============================================================================

Reply via email to