cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r328469 - in /cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal: LinkService.java impl/DefaultLinkService.java pluto/PortletURLProviderImpl.java pluto/servlet/ServletRequestImpl.java
Date Tue, 25 Oct 2005 20:19:01 GMT
Author: cziegeler
Date: Tue Oct 25 13:18:47 2005
New Revision: 328469

URL: http://svn.apache.org/viewcvs?rev=328469&view=rev
Log:
Start centralized handling of parameter forwarding to coplets

Modified:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/LinkService.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/DefaultLinkService.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/servlet/ServletRequestImpl.java

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/LinkService.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/LinkService.java?rev=328469&r1=328468&r2=328469&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/LinkService.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/LinkService.java Tue Oct 25 13:18:47
2005
@@ -124,4 +124,18 @@
      * @see javax.servlet.http.HttpServletResponse#encodeURL(java.lang.String) 
      */
     String encodeURL(String url);
+
+    /**
+     * A list of parameters that should be filtered when
+     * coplets are called. The list might consist of either
+     * a parameter name (string) or a prefix (string). A prefix
+     * ends with a '*'.
+     * @return A list of strings. This method always returns a list.
+     */
+    List getInternalParameterNames();
+
+    /**
+     * Test if the parameter is an internal one.
+     */
+    boolean isInternalParameterName(String name);
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/DefaultLinkService.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/DefaultLinkService.java?rev=328469&r1=328468&r2=328469&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/DefaultLinkService.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/DefaultLinkService.java
Tue Oct 25 13:18:47 2005
@@ -16,8 +16,10 @@
 package org.apache.cocoon.portal.impl;
 
 import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.StringTokenizer;
 
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.context.Context;
@@ -67,6 +69,12 @@
     /** Default port used for https. */
     protected int defaultSecurePort = 443;
 
+    /** List of internal parameters. */
+    protected List internalParameters = new ArrayList();
+
+    /** List of matchers for internal parameters. */
+    protected List internalParametersMatchers = new ArrayList();
+
     /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
@@ -81,6 +89,17 @@
     public void parameterize(Parameters params) throws ParameterException {
         this.defaultPort = params.getParameterAsInteger("defaultPort", this.defaultPort);
         this.defaultSecurePort = params.getParameterAsInteger("defaultSecurePort", this.defaultSecurePort);
+        final String internalParams = params.getParameter("internalParameters", "cocoon-*");
+        final StringTokenizer st = new StringTokenizer(internalParams, ",");
+        while ( st.hasMoreTokens() ) {
+            final String parameter = st.nextToken();
+            this.internalParameters.add(parameter);
+            if ( parameter.endsWith("*") ) {
+                this.internalParametersMatchers.add(new PrefixParameterMatcher(parameter));
+            } else {
+                this.internalParametersMatchers.add(new ConstantParameterMatcher(parameter));
+            }
+        }
     }
 
     /**
@@ -341,5 +360,48 @@
      */
     public void contextualize(Context context) throws ContextException {
         this.context = context;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.LinkService#getInternalParameterNames()
+     */
+    public List getInternalParameterNames() {
+        return this.internalParameters;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.LinkService#isInternalParameterName(java.lang.String)
+     */
+    public boolean isInternalParameterName(String name) {
+        final Iterator i = this.internalParametersMatchers.iterator();
+        while ( i.hasNext() ) {
+            final ParameterMatcher current = (ParameterMatcher)i.next();
+            if ( current.match(name) ) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public static interface ParameterMatcher {
+        boolean match(String name);
+    }
+    public static final class ConstantParameterMatcher implements ParameterMatcher {
+        protected final String name;
+        public ConstantParameterMatcher(String value) {
+            this.name = value;
+        }
+        public boolean match(String name) {
+            return this.name.equals(name);
+        }
+    }
+    public static final class PrefixParameterMatcher implements ParameterMatcher {
+        protected final String prefix;
+        public PrefixParameterMatcher(String prefix) {
+            this.prefix = prefix.substring(0, prefix.length()-1);
+        }
+        public boolean match(String name) {
+            return name.startsWith(this.prefix);
+        }
     }
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java?rev=328469&r1=328468&r2=328469&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/PortletURLProviderImpl.java
Tue Oct 25 13:18:47 2005
@@ -303,4 +303,8 @@
 
         return urlConverter.toString();
     }
+
+    public LinkService getLinkService() {
+        return this.linkService;
+    }
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/servlet/ServletRequestImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/servlet/ServletRequestImpl.java?rev=328469&r1=328468&r2=328469&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/servlet/ServletRequestImpl.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/servlet/ServletRequestImpl.java
Tue Oct 25 13:18:47 2005
@@ -137,7 +137,7 @@
                     String[] paramValues = this.getRequest().getParameterValues(paramName);
                     String[] values = (String[]) this.portletParameterMap.get(paramName);
 
-                    if ( !paramName.startsWith("cocoon-") ) {
+                    if ( !this.provider.getLinkService().isInternalParameterName(paramName)
) {
                         if (values != null) {
                             String[] temp = new String[paramValues.length + values.length];
                             System.arraycopy(paramValues, 0, temp, 0, paramValues.length);



Mime
View raw message