cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r507537 - in /cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services: ./ impl/ impl/links/
Date Wed, 14 Feb 2007 14:23:16 GMT
Author: cziegeler
Date: Wed Feb 14 06:23:15 2007
New Revision: 507537

URL: http://svn.apache.org/viewvc?view=rev&rev=507537
Log:
Start new improved link service

Added:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ConstantParameterMatcher.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/LinkInfo.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/NewLinkService.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ParameterMatcher.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/PrefixParameterMatcher.java
Modified:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LinkService.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLinkService.java

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LinkService.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LinkService.java?view=diff&rev=507537&r1=507536&r2=507537
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LinkService.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LinkService.java
Wed Feb 14 06:23:15 2007
@@ -35,8 +35,14 @@
     /** These parameters are used by default for adding portal specific information to a
url. */
     List DEFAULT_INTERNAL_PARAMETERS = Collections.singletonList("cocoon-*");
 
+    /**
+     * This object holds a 'complete' request parameter (or several) which means it
+     * contains a string like {name}={value}. The value should already be url encoded! 
+     */
     static class ParameterDescription {
+
         public final String parameters;
+
         public ParameterDescription(String parameters) {
             this.parameters = parameters;
         }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLinkService.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLinkService.java?view=diff&rev=507537&r1=507536&r2=507537
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLinkService.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLinkService.java
Wed Feb 14 06:23:15 2007
@@ -28,6 +28,9 @@
 import org.apache.cocoon.portal.event.ComparableEvent;
 import org.apache.cocoon.portal.event.Event;
 import org.apache.cocoon.portal.services.LinkService;
+import org.apache.cocoon.portal.services.impl.links.ConstantParameterMatcher;
+import org.apache.cocoon.portal.services.impl.links.ParameterMatcher;
+import org.apache.cocoon.portal.services.impl.links.PrefixParameterMatcher;
 import org.apache.cocoon.portal.util.AbstractBean;
 
 /**
@@ -340,29 +343,5 @@
             }
         }
         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 matchingName) {
-            return this.name.equals(matchingName);
-        }
-    }
-
-    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);
-        }
     }
 }

Added: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ConstantParameterMatcher.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ConstantParameterMatcher.java?view=auto&rev=507537
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ConstantParameterMatcher.java
(added)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ConstantParameterMatcher.java
Wed Feb 14 06:23:15 2007
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.cocoon.portal.services.impl.links;
+
+/**
+ * 
+ * @version $Id$
+ */
+public final class ConstantParameterMatcher implements ParameterMatcher {
+
+    protected final String name;
+
+    public ConstantParameterMatcher(String value) {
+        this.name = value;
+    }
+
+    public boolean match(String matchingName) {
+        return this.name.equals(matchingName);
+    }
+}
\ No newline at end of file

Added: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/LinkInfo.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/LinkInfo.java?view=auto&rev=507537
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/LinkInfo.java
(added)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/LinkInfo.java
Wed Feb 14 06:23:15 2007
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.cocoon.portal.services.impl.links;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.portal.event.ComparableEvent;
+import org.apache.cocoon.portal.event.Event;
+
+/**
+ * Helper class containing the information about common parts for each link
+ * that will be generated in the portal page.
+ *
+ * @version $Id: LinkInfo.java 449173 2006-09-23 05:52:37Z crossley $
+ */
+public class LinkInfo {
+
+    /** Link base contains the base url for the http protocol. */
+    protected final String       httpLinkBase;
+    protected final String       secureLinkBase;
+    protected List comparableEvents;
+    protected List events;
+    protected Map  parameters;
+
+    /** Is the page called using https? */
+    protected final boolean isSecure;
+
+    public LinkInfo(Request request, int defaultPort, int defaultSecurePort) {
+        this.isSecure = request.getScheme().equals("https");
+        // create relative url
+        String relativeURI = request.getSitemapURI();
+        final int pos = relativeURI.lastIndexOf('/');
+        if ( pos != -1 ) {
+            relativeURI = relativeURI.substring(pos+1);
+        }
+
+        // do we need a protocol shift for link base?
+        if ( this.isSecure ) {
+            this.httpLinkBase = this.getAbsoluteUrl(request, false, defaultPort);
+            this.secureLinkBase = relativeURI;
+        } else {
+            this.httpLinkBase = relativeURI;
+            this.secureLinkBase = this.getAbsoluteUrl(request, true, defaultSecurePort);
+        }
+    }
+
+    protected String getAbsoluteUrl(Request request, boolean useSecure, int port) {
+        final StringBuffer buffer = new StringBuffer();
+        if ( useSecure ) {
+            buffer.append("https://");
+        } else {
+            buffer.append("http://");
+        }
+        buffer.append(request.getServerName());
+        if (  (  useSecure && port != 443)
+           || ( !useSecure && port != 80 ) ) {
+            buffer.append(':');
+            buffer.append(port);
+        }
+        if ( request.getContextPath().length() > 0 ) {
+            buffer.append(request.getContextPath());
+        }
+        buffer.append('/');                        
+        if ( request.getSitemapURIPrefix().length() > 0 ) {
+            buffer.append(request.getSitemapURIPrefix());
+        }
+        buffer.append(request.getSitemapURI());
+        return buffer.toString();
+    }
+
+    public String getBase(Boolean secure) {
+        // if no information is provided, we stay with the same protocol
+        if ( (secure == null && this.isSecure ) || (secure != null && secure.booleanValue()
)) {
+            return this.secureLinkBase;
+        }
+        return this.httpLinkBase;
+    }
+
+    /**
+     * Delete a parameter.
+     */
+    public void deleteParameter(String parameterName) {
+        if ( this.parameters != null ) {
+            this.parameters.remove(parameterName);
+        }
+    }
+
+    /**
+     * Add a parameter to each link in this page.
+     */
+    public void addParameter(String name, String value) {
+        if ( this.parameters == null ) {
+            this.parameters = new HashMap();
+        }
+        // do we already have a value for this parameter?
+        final String[] previousValues = (String[]) this.parameters.get(name);
+        if ( previousValues == null ) {
+            this.parameters.put(name, new String[] {value});
+        } else {
+            final String[] newValues = new String[previousValues.length+1];
+            System.arraycopy(previousValues, 0, newValues, 0, previousValues.length);
+            newValues[previousValues.length] = value;
+            this.parameters.put(name, newValues);
+        }
+    }
+
+    /**
+     * Add an event to each link in this page.
+     */
+    public void addEvent(Event event) {
+        if ( event != null ) { 
+            if (event instanceof ComparableEvent) {
+                if ( this.comparableEvents != null ) {
+                    // search if we already have an event for this!
+                    final Iterator iter = this.comparableEvents.iterator();
+                    boolean found = false;
+                    while (!found && iter.hasNext()) {
+                        final ComparableEvent e = (ComparableEvent)iter.next();
+                        if (e.equalsEvent((ComparableEvent) event)) {
+                            found = true;
+                            iter.remove();
+                        }
+                    }
+                } else {
+                    this.comparableEvents = new ArrayList();
+                }
+                this.comparableEvents.add(event);
+            } else {
+                if ( this.events == null ) {
+                    this.events = new ArrayList();
+                }
+                this.events.add(event);
+            }
+        }
+    }
+}
\ No newline at end of file

Added: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/NewLinkService.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/NewLinkService.java?view=auto&rev=507537
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/NewLinkService.java
(added)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/NewLinkService.java
Wed Feb 14 06:23:15 2007
@@ -0,0 +1,354 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.cocoon.portal.services.impl.links;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.Response;
+import org.apache.cocoon.portal.PortalRuntimeException;
+import org.apache.cocoon.portal.event.ComparableEvent;
+import org.apache.cocoon.portal.event.Event;
+import org.apache.cocoon.portal.services.LinkService;
+import org.apache.cocoon.portal.util.AbstractBean;
+
+/**
+ * This is the default implementation of the {@link LinkService}.
+ * In order to work properly this component has to be configured with the correct
+ * ports.
+ *
+ * @version $Id$
+ */
+public class NewLinkService 
+    extends AbstractBean
+    implements LinkService {
+
+    /** Default port used for http. */
+    protected int defaultPort = 80;
+
+    /** Default port used for https. */
+    protected int defaultSecurePort = 443;
+
+    /** List of matchers for internal parameters. */
+    protected List internalParametersMatchers = new ArrayList();
+
+    /** The name of the request parameter for events. */
+    protected String requestParameterName = LinkService.DEFAULT_REQUEST_EVENT_PARAMETER_NAME;
+
+    /**
+     * Construct a new link service.
+     */
+    public NewLinkService() {
+        this.setInternalParameters(LinkService.DEFAULT_INTERNAL_PARAMETERS);
+    }
+
+    /**
+     * Set the default port for http.
+     */
+    public void setDefaultPort(int defaultPort) {
+        this.defaultPort = defaultPort;
+    }
+
+    /**
+     * Set the default port for https.
+     */
+    public void setDefaultSecurePort(int defaultSecurePort) {
+        this.defaultSecurePort = defaultSecurePort;
+    }
+
+    /**
+     * Set the request parameter name used for adding event information to the url.
+     */
+    public void setRequestParameterName(String requestParameterName) {
+        this.requestParameterName = requestParameterName;
+    }
+
+    /**
+     * Set the list of internal parameters.
+     */
+    public void setInternalParameters(List internalParams) {
+        this.internalParametersMatchers.clear();
+        if ( internalParams != null ) {
+            final Iterator i = internalParams.iterator();
+            while ( i.hasNext() ) {
+                final String parameter = i.next().toString();
+                if ( parameter.endsWith("*") ) {
+                    this.internalParametersMatchers.add(new PrefixParameterMatcher(parameter));
+                } else {
+                    this.internalParametersMatchers.add(new ConstantParameterMatcher(parameter));
+                }
+            }            
+        }
+    }
+
+    /**
+     * Return the current info for the request.
+     * @return A LinkInfo object.
+     */
+    protected LinkInfo getInfo() {
+        final Request request = ObjectModelHelper.getRequest(this.portalService.getProcessInfoProvider().getObjectModel());
+        LinkInfo info = (LinkInfo)request.getAttribute(NewLinkService.class.getName());
+        if ( info == null ) {
+            info = (LinkInfo)request.getAttribute(NewLinkService.class.getName());
+            if ( info == null ) {
+                info = new LinkInfo(request, this.defaultPort, this.defaultSecurePort);
+                request.setAttribute(NewLinkService.class.getName(), info);
+            }
+        }
+        return info;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.LinkService#isSecure()
+     */
+    public boolean isSecure() {
+        final Request request = ObjectModelHelper.getRequest(this.portalService.getProcessInfoProvider().getObjectModel());
+        return request.isSecure();
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.LinkService#encodeURL(String url)
+     */
+    public String encodeURL(String url) {
+        final Response response = ObjectModelHelper.getResponse(this.portalService.getProcessInfoProvider().getObjectModel());
+        return response.encodeURL(url);
+    }
+
+    /**
+     * Add one event to the buffer
+     * @return Returns true, if the link contains a parameter
+     */
+    protected boolean addEvent(StringBuffer buffer, Event event, boolean hasParams) {
+        if ( hasParams ) {
+            buffer.append('&');
+        } else {
+            buffer.append('?');
+        }
+        final String value = this.portalService.getEventConverter().encode(event);
+        try {
+            buffer.append(this.requestParameterName).append('=').append(URLEncoder.encode(value,
"utf-8"));
+        } catch (UnsupportedEncodingException uee) {
+            // ignore this as utf-8 is always supported
+        }
+        return true;
+    }
+
+    protected boolean addParameter(StringBuffer buffer, String name, String value, boolean
hasParams) {
+        if ( hasParams ) {
+            buffer.append('&');
+        } else {
+            buffer.append('?');
+        }
+        try {
+            buffer.append(name).append('=').append(URLEncoder.encode(value, "utf-8"));
+        } catch (UnsupportedEncodingException uee) {
+            // ignore this as utf-8 is always supported
+        }
+        return true;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.LinkService#getLinkURI(org.apache.cocoon.portal.event.Event)
+     */
+    public String getLinkURI(Event event) {
+        return this.getLinkURI(event, null);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.LinkService#getLinkURI(org.apache.cocoon.portal.event.Event,
Boolean)
+     */
+    public String getLinkURI(Event event, Boolean secure) {
+        return this.getLinkURI(Collections.singletonList(event), secure);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.LinkService#getLinkURI(java.util.List)
+     */
+    public String getLinkURI(List events) {
+        return this.getLinkURI(events, null);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.LinkService#getLinkURI(java.util.List)
+     */
+    public String getLinkURI(List events, Boolean secure) {
+        if (events == null || events.size() == 0) {
+            return this.getRefreshLinkURI(secure);
+        }
+        final LinkInfo info = this.getInfo();
+        final StringBuffer buffer = new StringBuffer(info.getBase(secure));
+        boolean hasParams = buffer.indexOf("?") != -1;
+
+        // add comparable events
+        if ( info.comparableEvents != null ) {
+            final Iterator iter = info.comparableEvents.iterator();
+            while (iter.hasNext()) {
+                final ComparableEvent current = (ComparableEvent)iter.next();
+    
+                final Iterator eventIterator = events.iterator();
+                boolean found = false;
+                while (!found && eventIterator.hasNext()) {
+                    final Object inEvent = eventIterator.next();
+                    if (inEvent instanceof ComparableEvent
+                        && current.equalsEvent((ComparableEvent) inEvent)) {
+                        found = true;
+                    }
+                }
+                hasParams = this.addEvent(buffer, current, hasParams);
+            }
+        }
+
+        // add events
+        if ( info.events != null ) {
+            final Iterator iter = info.events.iterator();
+            while (iter.hasNext()) {
+                final Event current = (Event)iter.next();
+                hasParams = this.addEvent(buffer, current, hasParams);
+            }
+        }
+
+        // add parameters
+        if ( info.parameters != null ) {
+            final Iterator iter = info.parameters.entrySet().iterator();
+            while ( iter.hasNext() ) {
+                final Map.Entry current = (Map.Entry)iter.next();
+                final String parameterName = current.getKey().toString();
+                final String [] values = (String[])current.getValue();
+                for(int i=0; i<values.length; i++) {
+                    hasParams = this.addParameter(buffer, parameterName, values[i], hasParams);
+                }
+            }
+        }
+
+        // now add supplied events and parameters
+        final Iterator iter = events.iterator();
+        while (iter.hasNext()) {
+            final Object current = iter.next();
+            if (current instanceof Event) {
+                hasParams = this.addEvent(buffer, (Event) current, hasParams);
+            } else if ( current instanceof ParameterDescription ) {
+                if (hasParams) {
+                    buffer.append('&');
+                } else {
+                    buffer.append('?');
+                    hasParams = true;
+                }
+                buffer.append(((ParameterDescription) current).parameters);
+            } else {
+                throw new PortalRuntimeException("Unknown object passed to create a link.
Only events " +
+                            "and parameter descriptions are allowed. Unknown object: " +
current);
+            }
+        }
+        return buffer.toString();
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.LinkService#addEventToLink(org.apache.cocoon.portal.event.Event)
+     */
+    public void addEventToLink(Event event) {
+        final LinkInfo info = this.getInfo();
+        info.addEvent(event);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.LinkService#addParameterToLink(java.lang.String,
java.lang.String)
+     */
+    public void addParameterToLink(String name, String value) {
+        final LinkInfo info = this.getInfo();
+        info.addParameter(name, value);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.LinkService#addUniqueParameterToLink(java.lang.String,
java.lang.String)
+     */
+    public void addUniqueParameterToLink(String name, String value) {
+        final LinkInfo info = this.getInfo();
+        info.deleteParameter(name);
+        info.addParameter(name, value);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.LinkService#getRefreshLinkURI()
+     */
+    public String getRefreshLinkURI() {
+        return this.getRefreshLinkURI(null);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.LinkService#getRefreshLinkURI(java.lang.Boolean)
+     */
+    public String getRefreshLinkURI(Boolean secure) {
+        final LinkInfo info = this.getInfo();
+
+        final StringBuffer buffer = new StringBuffer(info.getBase(secure));
+        boolean hasParams = buffer.indexOf("?") != -1;
+        
+        // add comparable events
+        if ( info.comparableEvents != null ) {
+            final Iterator iter = info.comparableEvents.iterator();
+            while (iter.hasNext()) {
+                final Event current = (Event)iter.next();
+                hasParams = this.addEvent(buffer, current, hasParams);
+            }
+        }
+
+        // add events
+        if ( info.events != null ) {
+            final Iterator iter = info.events.iterator();
+            while (iter.hasNext()) {
+                final Event current = (Event)iter.next();
+                hasParams = this.addEvent(buffer, current, hasParams);
+            }
+        }
+
+        // add parameters
+        if ( info.parameters != null ) {
+            final Iterator iter = info.parameters.entrySet().iterator();
+            while ( iter.hasNext() ) {
+                final Map.Entry current = (Map.Entry)iter.next();
+                final String parameterName = current.getKey().toString();
+                final String [] values = (String[])current.getValue();
+                for(int i=0; i<values.length; i++) {
+                    hasParams = this.addParameter(buffer, parameterName, values[i], hasParams);
+                }
+            }
+        }
+
+        return buffer.toString();
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.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;
+    }
+}

Added: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ParameterMatcher.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ParameterMatcher.java?view=auto&rev=507537
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ParameterMatcher.java
(added)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ParameterMatcher.java
Wed Feb 14 06:23:15 2007
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.cocoon.portal.services.impl.links;
+
+/**
+ * 
+ * @version $Id$
+ */
+public interface ParameterMatcher {
+
+    boolean match(String name);
+
+}
\ No newline at end of file

Added: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/PrefixParameterMatcher.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/PrefixParameterMatcher.java?view=auto&rev=507537
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/PrefixParameterMatcher.java
(added)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/PrefixParameterMatcher.java
Wed Feb 14 06:23:15 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.cocoon.portal.services.impl.links;
+
+/**
+ * 
+ * @version $Id$
+ */
+public final class PrefixParameterMatcher implements ParameterMatcher {
+
+    protected final String prefix;
+
+    public PrefixParameterMatcher(String prefix) {
+        if ( prefix.endsWith("*") ) {
+            this.prefix = prefix.substring(0, prefix.length()-1);
+        } else {
+            this.prefix = prefix;
+        }
+    }
+
+    public boolean match(String name) {
+        return name.startsWith(this.prefix);
+    }
+}
\ No newline at end of file



Mime
View raw message