cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r156633 - in cocoon/trunk/src: blocks/portal/java/org/apache/cocoon/portal/impl/ blocks/portal/java/org/apache/cocoon/portal/profile/impl/ java/org/apache/cocoon/components/source/
Date Wed, 09 Mar 2005 10:53:57 GMT
Author: cziegeler
Date: Wed Mar  9 02:53:53 2005
New Revision: 156633

URL: http://svn.apache.org/viewcvs?view=rev&rev=156633
Log:
Use NetUtils.encode with utf-8 as default instead of SourceUtil.encode

Modified:
    cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultLinkService.java
    cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/impl/PageLabelLinkService.java
    cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java
    cocoon/trunk/src/java/org/apache/cocoon/components/source/SourceUtil.java

Modified: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultLinkService.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultLinkService.java?view=diff&r1=156632&r2=156633
==============================================================================
--- cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultLinkService.java
(original)
+++ cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultLinkService.java
Wed Mar  9 02:53:53 2005
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.portal.impl;
 
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Iterator;
@@ -38,7 +39,7 @@
 import org.apache.cocoon.portal.event.EventConverter;
 import org.apache.cocoon.portal.event.RequestEvent;
 import org.apache.cocoon.portal.event.ConvertableEvent;
-import org.apache.excalibur.source.SourceUtil;
+import org.apache.cocoon.util.NetUtils;
 
 /**
  *
@@ -151,7 +152,11 @@
                 } else {
                     buffer.append('?');
                 }
-                buffer.append((String) objects[1]).append('=').append(SourceUtil.encode((String)
objects[2]));
+                try {
+                    buffer.append((String) objects[1]).append('=').append(NetUtils.encode((String)
objects[2], "utf-8"));
+                } catch (UnsupportedEncodingException uee) {
+                    // ignore this as utf-8 is always supported
+                }
                 hasParams = true;
             }
         }
@@ -174,7 +179,11 @@
         }
         StringBuffer value = new StringBuffer("");
         String parameterName = processEvent(event, value);
-        buffer.append(parameterName).append('=').append(SourceUtil.encode(value.toString()));
+        try {
+            buffer.append(parameterName).append('=').append(NetUtils.encode(value.toString(),
"utf-8"));
+        } catch (UnsupportedEncodingException uee) {
+            // ignore this as utf-8 is always supported
+        }
         return true;
     }
     
@@ -217,7 +226,11 @@
                 } else {
                     buffer.append('?');
                 }
-                buffer.append((String) objects[1]).append('=').append(SourceUtil.encode((String)
objects[2]));
+                try {
+                    buffer.append((String) objects[1]).append('=').append(NetUtils.encode((String)
objects[2], "utf-8"));
+                } catch (UnsupportedEncodingException uee) {
+                    // ignore this as utf-8 is always supported
+                }
                 hasParams = true;
             }
         }
@@ -279,7 +292,11 @@
         } else {
             info.linkBase.append('?');
         }
-        info.linkBase.append(name).append('=').append(SourceUtil.encode(value));
+        try {
+            info.linkBase.append(name).append('=').append(NetUtils.encode(value, "utf-8"));
+        } catch (UnsupportedEncodingException uee) {
+            // ignore this as utf-8 is always supported
+        }
         info.hasParameters = true;
     }
 
@@ -331,7 +348,11 @@
             } else {
                 buffer.append('?');
             }
-            buffer.append((String)objects[1]).append('=').append(SourceUtil.encode((String)objects[2]));
+            try {
+                buffer.append((String)objects[1]).append('=').append(NetUtils.encode((String)objects[2],
"utf-8"));
+            } catch (UnsupportedEncodingException uee) {
+                // ignore this as utf-8 is always supported
+            }
             hasParams = true;
         }
         return buffer.toString();
@@ -371,14 +392,13 @@
                 // Could not convert the event
                 value.append(this.converter.encode(event));
             } else {
-                String eventValue;
                 parameterName = DEFAULT_CONVERTABLE_EVENT_PARAMETER_NAME;
                 try {
-                    eventValue = SourceUtil.encode(eventStr, "utf-8");
-                } catch (Exception e) {
-                    eventValue = SourceUtil.encode(eventStr);
+                    String eventValue = NetUtils.encode(eventStr, "utf-8");
+                    value.append(eventParName).append('(').append(eventValue).append(')');
+                } catch (UnsupportedEncodingException uee) {
+                    // ignore this as utf-8 is always supported
                 }
-                value.append(eventParName).append('(').append(eventValue).append(')');
             }
         } else {
             if (event instanceof RequestEvent) {

Modified: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/impl/PageLabelLinkService.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/impl/PageLabelLinkService.java?view=diff&r1=156632&r2=156633
==============================================================================
--- cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/impl/PageLabelLinkService.java
(original)
+++ cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/impl/PageLabelLinkService.java
Wed Mar  9 02:53:53 2005
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.portal.impl;
 
+import java.io.UnsupportedEncodingException;
 import java.util.Iterator;
 import java.util.List;
 
@@ -23,9 +24,9 @@
 import org.apache.cocoon.portal.layout.CompositeLayout;
 import org.apache.cocoon.portal.layout.Item;
 import org.apache.cocoon.portal.layout.NamedItem;
+import org.apache.cocoon.util.NetUtils;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.excalibur.source.SourceUtil;
 
 /**
  * The PageLabelLinkService generates links for named items defined in the layout portal.xml.
@@ -33,7 +34,7 @@
  *
  * @author Ralph Goers
  *
- * @version CVS $Id: $
+ * @version CVS $Id:$
  */
 public class PageLabelLinkService extends DefaultLinkService {
 
@@ -99,13 +100,12 @@
                     else {
                         buffer.append('?');
                     }
-                    String encodedKey;
                     try {
-                        encodedKey = SourceUtil.encode(key.toString(), "utf-8");
-                    } catch (Exception ex) {
-                        encodedKey = SourceUtil.encode(key.toString());
+                        String encodedKey = NetUtils.encode(key.toString(), "utf-8");
+                        buffer.append(requestParameterName).append('=').append(encodedKey);
+                    } catch (UnsupportedEncodingException uee) {
+                        // ignore this as utf-8 is always supported
                     }
-                    buffer.append(requestParameterName).append('=').append(encodedKey);
                     return buffer.toString();
                 }
             }
@@ -183,8 +183,12 @@
             else {
                 buffer.append('?');
             }
-            buffer.append(requestParameterName).append('=')
-                .append(SourceUtil.encode(value.toString()));
+            try {
+                buffer.append(requestParameterName).append('=')
+                      .append(NetUtils.encode(value.toString(), "utf-8"));
+            } catch (UnsupportedEncodingException uee) {
+                // ignore this as utf-8 is always supported
+            }
 
             return buffer.toString();
         }
@@ -249,13 +253,12 @@
         } else {
             uri.append('?');
         }
-        String encodedLabel;
         try {
-            encodedLabel = SourceUtil.encode(label, "utf-8");
-        } catch (Exception e) {
-            encodedLabel = SourceUtil.encode(label);
+            String encodedLabel = NetUtils.encode(label, "utf-8");
+            uri.append(parmName).append('=').append(encodedLabel);
+        } catch (UnsupportedEncodingException uee) {
+            // ignore this as utf-8 is always supported
         }
-        uri.append(parmName).append('=').append(encodedLabel);
         return uri.toString();
     }
 }

Modified: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java?view=diff&r1=156632&r2=156633
==============================================================================
--- cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java
(original)
+++ cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java
Wed Mar  9 02:53:53 2005
@@ -18,6 +18,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -30,11 +31,11 @@
 import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.components.persistence.CastorSourceConverter;
 import org.apache.cocoon.portal.profile.ProfileLS;
+import org.apache.cocoon.util.NetUtils;
 import org.apache.cocoon.xml.dom.DOMUtil;
 import org.apache.excalibur.source.ModifiableSource;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
-import org.apache.excalibur.source.SourceUtil;
 import org.apache.excalibur.source.SourceValidity;
 import org.apache.excalibur.xml.sax.SAXParser;
 import org.apache.excalibur.xml.xpath.XPathProcessor;
@@ -191,7 +192,11 @@
             converter.storeObject(writer, parameters, profile);
 
             buffer.append("&content=");
-            buffer.append(SourceUtil.encode(writer.toString()));
+            try {
+                buffer.append(NetUtils.encode(writer.toString(), "utf-8"));
+            } catch (UnsupportedEncodingException uee) {
+                // ignore this as utf-8 is always supported
+            }
 
             source = resolver.resolveURI(buffer.toString());
 

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/source/SourceUtil.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/source/SourceUtil.java?view=diff&r1=156632&r2=156633
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/source/SourceUtil.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/source/SourceUtil.java Wed Mar  9 02:53:53
2005
@@ -32,6 +32,7 @@
 import org.apache.cocoon.ResourceNotFoundException;
 import org.apache.cocoon.environment.internal.EnvironmentHelper;
 import org.apache.cocoon.serialization.Serializer;
+import org.apache.cocoon.util.NetUtils;
 import org.apache.cocoon.xml.IncludeXMLConsumer;
 import org.apache.cocoon.xml.XMLUtils;
 import org.apache.cocoon.xml.dom.DOMBuilder;
@@ -61,7 +62,7 @@
  *
  * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
- * @version CVS $Id: SourceUtil.java,v 1.21 2004/06/18 14:28:56 vgritsenko Exp $
+ * @version CVS $Id$
  */
 public final class SourceUtil {
 
@@ -415,7 +416,7 @@
                         buffer.append(separator)
                                 .append(current)
                                 .append('=')
-                                .append(org.apache.excalibur.source.SourceUtil.encode((String)
values.next()));
+                                .append(NetUtils.encode((String) values.next(), "utf-8"));
                         separator = '&';
                     }
                 }



Mime
View raw message