cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r124357 - /cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/ApplicationCopletAdapter.java /cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java
Date Thu, 06 Jan 2005 10:39:24 GMT
Author: cziegeler
Date: Thu Jan  6 02:39:23 2005
New Revision: 124357

URL: http://svn.apache.org/viewcvs?view=rev&rev=124357
Log:
Fix problems with forms
Modified:
   cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/ApplicationCopletAdapter.java
   cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java

Modified: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/ApplicationCopletAdapter.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/ApplicationCopletAdapter.java?view=diff&rev=124357&p1=cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/ApplicationCopletAdapter.java&r1=124356&p2=cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/ApplicationCopletAdapter.java&r2=124357
==============================================================================
--- cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/ApplicationCopletAdapter.java
(original)
+++ cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/ApplicationCopletAdapter.java
Thu Jan  6 02:39:23 2005
@@ -15,8 +15,15 @@
  */
 package org.apache.cocoon.portal.coplet.adapter.impl;
 
+import java.io.UnsupportedEncodingException;
+import java.util.Enumeration;
+import java.util.Map;
+
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.components.ContextHelper;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.portal.coplet.CopletData;
 import org.apache.cocoon.portal.coplet.CopletFactory;
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
@@ -29,6 +36,7 @@
 import org.apache.cocoon.portal.layout.impl.CopletLayout;
 import org.apache.cocoon.portal.profile.ProfileManager;
 import org.apache.cocoon.portal.transformation.ProxyTransformer;
+import org.apache.cocoon.util.NetUtils;
 import org.apache.cocoon.xml.XMLUtils;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
@@ -82,7 +90,40 @@
             } else {
                 // this is a normal link event, so save the url in the instance data
                 // for ProxyTransformer
-                coplet.setTemporaryAttribute(ProxyTransformer.LINK, event.getLink());
+                String linkValue = event.getLink();
+                Boolean addParams = (Boolean)this.getConfiguration(coplet, "appendParameters");
+                if ( addParams != null && addParams.booleanValue() ) {
+                    final StringBuffer uri = new StringBuffer(event.getLink());
+                    boolean hasParams = (uri.indexOf("?") != -1);
+                    
+                    // append parameters - if any
+                    final Map objectModel = ContextHelper.getObjectModel(this.context);
+                    final Request r = ObjectModelHelper.getRequest(objectModel);
+                    final Enumeration params = r.getParameterNames();
+                    while (params.hasMoreElements()) {
+                        final String name = (String)params.nextElement();
+                        if (!name.startsWith("cocoon-portal-")) {
+                            final String[] values = r.getParameterValues(name);
+                            for(int i = 0; i < values.length; i++) {
+                                if ( hasParams ) {
+                                    uri.append('&');
+                                } else {
+                                    uri.append('?');
+                                    hasParams = true;
+                                }
+                                uri.append(name);
+                                uri.append('=');
+                                try {
+                                    uri.append(NetUtils.decode(values[i], "utf-8"));
+                                } catch (UnsupportedEncodingException uee) {
+                                    // ignore this
+                                }
+                            }
+                        }
+                    }
+                    linkValue = uri.toString();
+                }
+                coplet.setTemporaryAttribute(ProxyTransformer.LINK, linkValue);
             }
         }
     }

Modified: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java
Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java?view=diff&rev=124357&p1=cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java&r1=124356&p2=cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java&r2=124357
==============================================================================
--- cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java
(original)
+++ cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/transformation/ProxyTransformer.java
Thu Jan  6 02:39:23 2005
@@ -71,7 +71,7 @@
     /**
      * Parameter for specifying the envelope tag
      */
-    public static String ENVELOPE_TAG_PARAMETER = "envelope-tag";
+    public static final String ENVELOPE_TAG_PARAMETER = "envelope-tag";
 
     public static final String PORTALNAME = "cocoon-portal-portalname";
     public static final String COPLETID = "cocoon-portal-copletid";
@@ -90,7 +90,7 @@
     /**
      * Parameter for specifying the java protocol handler (used for https)
      */
-    public static String PROTOCOL_HANDLER_PARAMETER = "protocol-handler";
+    public static final String PROTOCOL_HANDLER_PARAMETER = "protocol-handler";
 
     /**
      * The document base uri
@@ -173,7 +173,7 @@
         this.copletInstanceData = getInstanceData(this.manager, objectModel, parameters);
 
         final CopletData copletData = this.copletInstanceData.getCopletData();
-        
+
         final String startURI = (String)copletData.getAttribute(START_URI);
 
         this.link = (String) this.copletInstanceData.getTemporaryAttribute(LINK);
@@ -209,7 +209,7 @@
         this.link = null;
         this.request = null;
     }
-    
+
     /**
      * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
      */
@@ -239,13 +239,20 @@
             } catch (MalformedURLException ex) {
                 throw new SAXException(ex);
             }
-
-            StringBuffer query = new StringBuffer();
-
             boolean firstparameter = true;
-            Enumeration enumeration = request.getParameterNames();
-
             boolean post = ("POST".equals(request.getMethod()));
+            int pos = remoteURI.indexOf('?');
+            final StringBuffer query = new StringBuffer();
+            if ( pos != -1 ) {
+                if ( !post ) {
+                    query.append('?');                    
+                }
+                query.append(remoteURI.substring(pos+1));
+                firstparameter = true;
+                remoteURI = remoteURI.substring(0, pos);
+            }
+
+            Enumeration enumeration = request.getParameterNames();
 
             while (enumeration.hasMoreElements()) {
                 String paramName = (String) enumeration.nextElement();
@@ -274,6 +281,9 @@
             Document result = null;
             try {
                 do {
+                    if ( this.getLogger().isDebugEnabled() ) {
+                        this.getLogger().debug("Invoking '" + remoteURI + query.toString()
+"', post="+post);
+                    }
                     HttpURLConnection connection =
                         connect(request, remoteURI, query.toString(), post);
                     remoteURI = checkForRedirect(connection, documentBase);
@@ -339,7 +349,6 @@
                 newURI = resolveURI(newURI, documentBase);
             }
             return newURI;
-
         }
         return null;
     }
@@ -557,14 +566,14 @@
     * @throws MalformedURLException if uri or document base is malformed.
     */
     public static String resolveURI(String uri, String documentBase)
-        throws MalformedURLException {
-
-        if (uri.indexOf("://") > -1) {
-            return uri;
-        }
+    throws MalformedURLException {
 
         if (uri == null) {
             throw new IllegalArgumentException("URI to be resolved must not be null!");
+        }
+
+        if (uri.indexOf("://") > -1) {
+            return uri;
         }
 
         if (documentBase == null) {

Mime
View raw message