cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r511812 [1/2] - in /cocoon/trunk/blocks/cocoon-portal: cocoon-portal-api/ cocoon-portal-bridges-impl/src/main/resources/ cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ cocoon-portal-impl/src/main/java/org/apache/coc...
Date Mon, 26 Feb 2007 14:17:01 GMT
Author: cziegeler
Date: Mon Feb 26 06:16:59 2007
New Revision: 511812

URL: http://svn.apache.org/viewvc?view=rev&rev=511812
Log:
Correct properties

Removed:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-bridges-impl/src/main/resources/
Modified:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-api/pom.xml   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultPortalManager.java   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ConstantParameterMatcher.java   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/DefaultLinkService.java   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/LinkInfo.java   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ParameterMatcher.java   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/PrefixParameterMatcher.java   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/test/java/org/apache/cocoon/portal/MockProcessInfoProvider.java   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/resources/org/apache/cocoon/portal/pluto/deployment/portlet.tld   (props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/avalon/cocoon-portal-sample.xconf   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-borderless-window.xml   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-column.xml   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-decorated-frame.xml   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-frame.xml   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-link.xml   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-linktab.xml   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-nowindow.xml   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-rawtab.xml   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-row.xml   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-tab.xml   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/renderer-window.xml   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/portal-sample.xsamples   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sitemap/src/main/java/org/apache/cocoon/portal/acting/helpers/FullScreenMapping.java   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sitemap/src/main/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java   (contents, props changed)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-tools-impl/src/main/java/org/apache/cocoon/portal/tools/service/UserRightsService.java   (contents, props changed)

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-api/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-api/pom.xml?view=diff&rev=511812&r1=511811&r2=511812
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-api/pom.xml (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-api/pom.xml Mon Feb 26 06:16:59 2007
@@ -1,68 +1,68 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
--->
-<!--+
-    | @version $Id: pom.xml 483960 2006-12-08 12:28:55Z reinhard $
-    +-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-  <parent>
-    <groupId>org.apache.cocoon</groupId>
-    <artifactId>cocoon-portal</artifactId>
-    <version>1-SNAPSHOT</version>
-  </parent>
-  <modelVersion>4.0.0</modelVersion>
-  <artifactId>cocoon-portal-api</artifactId>
-  <version>1.0.0-SNAPSHOT</version>
-  <packaging>jar</packaging>
-  <name>Portal Block API</name>
-  
-  <distributionManagement>
-    <site>
-      <id>website</id>
-      <url>${docs.deploymentBaseUrl}/blocks/portal/${docs.version}/</url>
-    </site>
-  </distributionManagement>
-
-  <properties>
-    <docs.name>Cocoon Portal</docs.name>    
-    <docs.version>1.0</docs.version>
-  </properties>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.daisycms</groupId>
-        <artifactId>daisy-maven-plugin</artifactId>
-        <configuration>        
-          <navDocId>1234</navDocId>
-          <collection>cdocs-portal</collection>          
-          <skipFirstNavigationDocumentLevel>true</skipFirstNavigationDocumentLevel>
-        </configuration>
-      </plugin>      
-    </plugins>
-  </build>
-  <dependencies>
-    <dependency>
-      <groupId>commons-lang</groupId>
-      <artifactId>commons-lang</artifactId>
-      <version>2.3</version>
-    </dependency>
-  </dependencies>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<!--+
+    | @version $Id$
+    +-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <parent>
+    <groupId>org.apache.cocoon</groupId>
+    <artifactId>cocoon-portal</artifactId>
+    <version>1-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>cocoon-portal-api</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <name>Portal Block API</name>
+  
+  <distributionManagement>
+    <site>
+      <id>website</id>
+      <url>${docs.deploymentBaseUrl}/blocks/portal/${docs.version}/</url>
+    </site>
+  </distributionManagement>
+
+  <properties>
+    <docs.name>Cocoon Portal</docs.name>    
+    <docs.version>1.0</docs.version>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.daisycms</groupId>
+        <artifactId>daisy-maven-plugin</artifactId>
+        <configuration>        
+          <navDocId>1234</navDocId>
+          <collection>cdocs-portal</collection>          
+          <skipFirstNavigationDocumentLevel>true</skipFirstNavigationDocumentLevel>
+        </configuration>
+      </plugin>      
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.3</version>
+    </dependency>
+  </dependencies>
+</project>

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-api/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-api/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java?view=diff&rev=511812&r1=511811&r2=511812
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java Mon Feb 26 06:16:59 2007
@@ -29,7 +29,7 @@
  * This data object is used for loading the profile. It decouples the
  * portal from the used authentication method.
  *
- * @version $Id: MapProfileLS.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ * @version $Id$
  */
 public abstract class AbstractPortalUser
     implements PortalUser, Serializable {

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java?view=diff&rev=511812&r1=511811&r2=511812
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java Mon Feb 26 06:16:59 2007
@@ -65,7 +65,7 @@
  * 
  * THIS IS A WORK IN PROGRESS - IT'S NOT FINISHED YET
  * 
- * @version $Id: AbstractUserProfileManager.java 37123 2004-08-27 12:11:53Z cziegeler $
+ * @version $Id$
  */
 public class GroupBasedProfileManager 
     extends AbstractProfileManager { 

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultPortalManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultPortalManager.java?view=diff&rev=511812&r1=511811&r2=511812
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultPortalManager.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultPortalManager.java Mon Feb 26 06:16:59 2007
@@ -1,249 +1,249 @@
-/*
- * 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;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.cocoon.ajax.AjaxHelper;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Request;
-import org.apache.cocoon.portal.PortalException;
-import org.apache.cocoon.portal.layout.renderer.Renderer;
-import org.apache.cocoon.portal.om.CopletInstance;
-import org.apache.cocoon.portal.om.CopletInstanceFeatures;
-import org.apache.cocoon.portal.om.Layout;
-import org.apache.cocoon.portal.om.LayoutException;
-import org.apache.cocoon.portal.om.LayoutFeatures;
-import org.apache.cocoon.portal.profile.ProfileManager;
-import org.apache.cocoon.portal.services.PortalManager;
-import org.apache.cocoon.portal.services.aspects.RequestProcessorAspect;
-import org.apache.cocoon.portal.services.aspects.RequestProcessorAspectContext;
-import org.apache.cocoon.portal.services.aspects.ResponseProcessorAspect;
-import org.apache.cocoon.portal.services.aspects.ResponseProcessorAspectContext;
-import org.apache.cocoon.portal.services.aspects.impl.support.RequestProcessorAspectContextImpl;
-import org.apache.cocoon.portal.services.aspects.impl.support.ResponseProcessorAspectContextImpl;
-import org.apache.cocoon.portal.services.aspects.support.AspectChain;
-import org.apache.cocoon.portal.util.AbstractBean;
-import org.apache.cocoon.xml.AttributesImpl;
-import org.apache.cocoon.xml.XMLUtils;
-import org.apache.commons.lang.StringUtils;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- *
- * @version $Id: PortalManagerImpl.java 507453 2007-02-14 09:41:57Z cziegeler $
- */
-public class DefaultPortalManager
-	extends AbstractBean
-	implements PortalManager, RequestProcessorAspect, ResponseProcessorAspect {
-
-    /** The aspect chain for additional request processing. */
-    protected AspectChain requestChain;
-
-    /** The aspect chain for additional response processing. */
-    protected AspectChain responseChain;
-
-    /**
-     * Set the request aspect chain.
-     * @param a A chain.
-     */
-    public void setRequestAspectChain(AspectChain a) {
-        this.requestChain = a;
-    }
-
-    /**
-     * Set the response aspect chain.
-     * @param a A chain.
-     */
-    public void setResponseAspectChain(AspectChain a) {
-        this.responseChain = a;
-    }
-
-    /**
-     * @see org.apache.cocoon.portal.services.PortalManager#process()
-     */
-    public void process()
-    throws PortalException {
-        RequestProcessorAspectContextImpl aspectContext =
-            new RequestProcessorAspectContextImpl(this.portalService, this.requestChain);
-        aspectContext.invokeNext();
-    }
-
-	/**
-	 * @see PortalManager#render(ContentHandler, Properties)
-	 */
-	public void render(ContentHandler contentHandler, Properties properties)
-    throws SAXException {
-        ResponseProcessorAspectContextImpl aspectContext =
-            new ResponseProcessorAspectContextImpl(this.portalService, this.responseChain);
-        aspectContext.invokeNext(contentHandler, properties);
-	}
-
-    /**
-     * Initialize
-     */
-    public void init()
-    throws PortalException {
-        if ( this.requestChain == null ) {
-            this.requestChain = new AspectChain(RequestProcessorAspect.class);
-        }
-        this.requestChain.addAspect(this, null);
-        if ( this.responseChain == null ) {
-            this.responseChain = new AspectChain(ResponseProcessorAspect.class);
-        }
-        this.responseChain.addAspect(this, null);
-    }
-
-    /**
-     * @see org.apache.cocoon.portal.services.aspects.RequestProcessorAspect#process(org.apache.cocoon.portal.services.aspects.RequestProcessorAspectContext)
-     */
-    public void process(RequestProcessorAspectContext rpContext) {
-        // by defaut, we have nothing to do
-    }
-
-    /**
-     * @see org.apache.cocoon.portal.services.aspects.ResponseProcessorAspect#render(org.apache.cocoon.portal.services.aspects.ResponseProcessorAspectContext, org.xml.sax.ContentHandler, java.util.Properties)
-     */
-    public void render(ResponseProcessorAspectContext renderContext,
-                       ContentHandler                   ch,
-                       Properties                       properties)
-    throws SAXException {
-        final ProfileManager profileManager = this.portalService.getProfileManager();
-
-        final Request req = ObjectModelHelper.getRequest(this.portalService.getProcessInfoProvider().getObjectModel());
-        // check for render parameters
-        // if a parameter for a layout or a coplet is defined
-        // then only this coplet or layout object is rendered
-        final String copletId = (properties == null ? null : properties.getProperty(PortalManager.PROPERTY_RENDER_COPLET, null));
-        final String layoutId = (properties == null ? null : properties.getProperty(PortalManager.PROPERTY_RENDER_LAYOUT, null));
-        if ( StringUtils.isNotEmpty(copletId) && StringUtils.isNotEmpty(layoutId) ) {
-            throw new SAXException("Only one of the paramteters can be specified for rendering: coplet or layout.");
-        }
-        Layout portalLayout = null;
-
-        if ( StringUtils.isNotEmpty(copletId) ) {
-            final CopletInstance cid = profileManager.getCopletInstance(copletId);
-            if ( cid != null ) {
-                portalLayout = LayoutFeatures.searchLayout(this.portalService, cid.getId(), profileManager.getLayout(null));
-                if ( portalLayout == null) {
-                    getLogger().error("No Layout to render for coplet instance with id: " + copletId);
-                    return;
-                }
-            }
-        } else if ( StringUtils.isNotEmpty(layoutId) ) {
-            portalLayout = profileManager.getLayout(layoutId);
-            if ( portalLayout == null) {
-                getLogger().error("No Layout to render for layout instance with id: " + layoutId);
-                return;
-            }
-        }
-
-        ch.startDocument();
-
-        // If no parameter is specified test for ajax request which will
-        // only render the changed coplets
-        if ( portalLayout == null && AjaxHelper.isAjaxRequest(req) ) {
-            Layout rootLayout = profileManager.getLayout(null);
-            XMLUtils.startElement(ch, "coplets");
-            final List changed = CopletInstanceFeatures.getChangedCopletInstanceDataObjects(this.portalService);
-            final Iterator i = changed.iterator();
-            while ( i.hasNext() ) {
-                final CopletInstance current = (CopletInstance)i.next();
-                final AttributesImpl a = new AttributesImpl();
-                a.addCDATAAttribute("id", current.getId());
-                XMLUtils.startElement(ch, "coplet", a);
-                final Layout l = LayoutFeatures.searchLayout(this.portalService, current.getId(), rootLayout);
-                Renderer portalLayoutRenderer = this.portalService.getRenderer( this.portalService.getLayoutFactory().getRendererName(l));
-                try {
-                    portalLayoutRenderer.toSAX(l, this.portalService, ch);
-                } catch (LayoutException e) {
-                    throw new SAXException(e);
-                }
-                XMLUtils.endElement(ch, "coplet");
-            }
-            XMLUtils.endElement(ch, "coplets");
-        } else {
-            if ( StringUtils.isNotEmpty(copletId) ) {
-                XMLUtils.startElement(ch, "coplets");
-                final AttributesImpl a = new AttributesImpl();
-                a.addCDATAAttribute("id", copletId);
-                XMLUtils.startElement(ch, "coplet", a);
-            } else if ( StringUtils.isNotEmpty(layoutId) ) {
-                final AttributesImpl a = new AttributesImpl();
-                a.addCDATAAttribute("id", layoutId);
-                XMLUtils.startElement(ch, "layout", a);
-            }
-
-            // if no render parameter is specified we render the whole page or just the full screen coplet
-            if ( portalLayout == null ) {
-                // first check for a full screen layout
-                portalLayout = LayoutFeatures.getFullScreenInfo(this.portalService);
-                if ( portalLayout == null ) {
-                    portalLayout = profileManager.getLayout(null);
-                }
-            }
-
-            try {
-                final Renderer portalLayoutRenderer = this.portalService.getRenderer( this.portalService.getLayoutFactory().getRendererName(portalLayout));
-
-                portalLayoutRenderer.toSAX(portalLayout, this.portalService, ch);
-            } catch (LayoutException e) {
-                throw new SAXException(e);
-            }
-            if ( StringUtils.isNotEmpty(copletId) ) {
-                XMLUtils.endElement(ch, "coplet");
-                XMLUtils.endElement(ch, "coplets");
-            } else if ( StringUtils.isNotEmpty(layoutId) ) {
-                XMLUtils.endElement(ch, "layout");
-            }
-        }
-
-        ch.endDocument();
-        // although we should be the last in the queue,
-        // let's invoke the next
-        renderContext.invokeNext(ch, properties);
-    }
-
-    /**
-     * @see org.apache.cocoon.portal.services.PortalManager#register(org.apache.cocoon.portal.services.aspects.ResponseProcessorAspect)
-     */
-    public void register(ResponseProcessorAspect aspect) {
-        try {
-            this.responseChain.addAspect(aspect, null, 0);
-        } catch (PortalException pe) {
-            final IllegalArgumentException e = new IllegalArgumentException("Unable to add portal manager aspects.");
-            e.initCause(pe);
-            throw e;
-        }
-    }
-
-    /**
-     * @see org.apache.cocoon.portal.services.PortalManager#register(org.apache.cocoon.portal.services.aspects.RequestProcessorAspect)
-     */
-    public void register(RequestProcessorAspect aspect) {
-        try {
-            this.responseChain.addAspect(aspect, null, 0);
-        } catch (PortalException pe) {
-            final IllegalArgumentException e = new IllegalArgumentException("Unable to add portal manager aspects.");
-            e.initCause(pe);
-            throw e;
-        }
-    }
-}
+/*
+ * 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;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.cocoon.ajax.AjaxHelper;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.portal.PortalException;
+import org.apache.cocoon.portal.layout.renderer.Renderer;
+import org.apache.cocoon.portal.om.CopletInstance;
+import org.apache.cocoon.portal.om.CopletInstanceFeatures;
+import org.apache.cocoon.portal.om.Layout;
+import org.apache.cocoon.portal.om.LayoutException;
+import org.apache.cocoon.portal.om.LayoutFeatures;
+import org.apache.cocoon.portal.profile.ProfileManager;
+import org.apache.cocoon.portal.services.PortalManager;
+import org.apache.cocoon.portal.services.aspects.RequestProcessorAspect;
+import org.apache.cocoon.portal.services.aspects.RequestProcessorAspectContext;
+import org.apache.cocoon.portal.services.aspects.ResponseProcessorAspect;
+import org.apache.cocoon.portal.services.aspects.ResponseProcessorAspectContext;
+import org.apache.cocoon.portal.services.aspects.impl.support.RequestProcessorAspectContextImpl;
+import org.apache.cocoon.portal.services.aspects.impl.support.ResponseProcessorAspectContextImpl;
+import org.apache.cocoon.portal.services.aspects.support.AspectChain;
+import org.apache.cocoon.portal.util.AbstractBean;
+import org.apache.cocoon.xml.AttributesImpl;
+import org.apache.cocoon.xml.XMLUtils;
+import org.apache.commons.lang.StringUtils;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ *
+ * @version $Id$
+ */
+public class DefaultPortalManager
+	extends AbstractBean
+	implements PortalManager, RequestProcessorAspect, ResponseProcessorAspect {
+
+    /** The aspect chain for additional request processing. */
+    protected AspectChain requestChain;
+
+    /** The aspect chain for additional response processing. */
+    protected AspectChain responseChain;
+
+    /**
+     * Set the request aspect chain.
+     * @param a A chain.
+     */
+    public void setRequestAspectChain(AspectChain a) {
+        this.requestChain = a;
+    }
+
+    /**
+     * Set the response aspect chain.
+     * @param a A chain.
+     */
+    public void setResponseAspectChain(AspectChain a) {
+        this.responseChain = a;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.PortalManager#process()
+     */
+    public void process()
+    throws PortalException {
+        RequestProcessorAspectContextImpl aspectContext =
+            new RequestProcessorAspectContextImpl(this.portalService, this.requestChain);
+        aspectContext.invokeNext();
+    }
+
+	/**
+	 * @see PortalManager#render(ContentHandler, Properties)
+	 */
+	public void render(ContentHandler contentHandler, Properties properties)
+    throws SAXException {
+        ResponseProcessorAspectContextImpl aspectContext =
+            new ResponseProcessorAspectContextImpl(this.portalService, this.responseChain);
+        aspectContext.invokeNext(contentHandler, properties);
+	}
+
+    /**
+     * Initialize
+     */
+    public void init()
+    throws PortalException {
+        if ( this.requestChain == null ) {
+            this.requestChain = new AspectChain(RequestProcessorAspect.class);
+        }
+        this.requestChain.addAspect(this, null);
+        if ( this.responseChain == null ) {
+            this.responseChain = new AspectChain(ResponseProcessorAspect.class);
+        }
+        this.responseChain.addAspect(this, null);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.aspects.RequestProcessorAspect#process(org.apache.cocoon.portal.services.aspects.RequestProcessorAspectContext)
+     */
+    public void process(RequestProcessorAspectContext rpContext) {
+        // by defaut, we have nothing to do
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.aspects.ResponseProcessorAspect#render(org.apache.cocoon.portal.services.aspects.ResponseProcessorAspectContext, org.xml.sax.ContentHandler, java.util.Properties)
+     */
+    public void render(ResponseProcessorAspectContext renderContext,
+                       ContentHandler                   ch,
+                       Properties                       properties)
+    throws SAXException {
+        final ProfileManager profileManager = this.portalService.getProfileManager();
+
+        final Request req = ObjectModelHelper.getRequest(this.portalService.getProcessInfoProvider().getObjectModel());
+        // check for render parameters
+        // if a parameter for a layout or a coplet is defined
+        // then only this coplet or layout object is rendered
+        final String copletId = (properties == null ? null : properties.getProperty(PortalManager.PROPERTY_RENDER_COPLET, null));
+        final String layoutId = (properties == null ? null : properties.getProperty(PortalManager.PROPERTY_RENDER_LAYOUT, null));
+        if ( StringUtils.isNotEmpty(copletId) && StringUtils.isNotEmpty(layoutId) ) {
+            throw new SAXException("Only one of the paramteters can be specified for rendering: coplet or layout.");
+        }
+        Layout portalLayout = null;
+
+        if ( StringUtils.isNotEmpty(copletId) ) {
+            final CopletInstance cid = profileManager.getCopletInstance(copletId);
+            if ( cid != null ) {
+                portalLayout = LayoutFeatures.searchLayout(this.portalService, cid.getId(), profileManager.getLayout(null));
+                if ( portalLayout == null) {
+                    getLogger().error("No Layout to render for coplet instance with id: " + copletId);
+                    return;
+                }
+            }
+        } else if ( StringUtils.isNotEmpty(layoutId) ) {
+            portalLayout = profileManager.getLayout(layoutId);
+            if ( portalLayout == null) {
+                getLogger().error("No Layout to render for layout instance with id: " + layoutId);
+                return;
+            }
+        }
+
+        ch.startDocument();
+
+        // If no parameter is specified test for ajax request which will
+        // only render the changed coplets
+        if ( portalLayout == null && AjaxHelper.isAjaxRequest(req) ) {
+            Layout rootLayout = profileManager.getLayout(null);
+            XMLUtils.startElement(ch, "coplets");
+            final List changed = CopletInstanceFeatures.getChangedCopletInstanceDataObjects(this.portalService);
+            final Iterator i = changed.iterator();
+            while ( i.hasNext() ) {
+                final CopletInstance current = (CopletInstance)i.next();
+                final AttributesImpl a = new AttributesImpl();
+                a.addCDATAAttribute("id", current.getId());
+                XMLUtils.startElement(ch, "coplet", a);
+                final Layout l = LayoutFeatures.searchLayout(this.portalService, current.getId(), rootLayout);
+                Renderer portalLayoutRenderer = this.portalService.getRenderer( this.portalService.getLayoutFactory().getRendererName(l));
+                try {
+                    portalLayoutRenderer.toSAX(l, this.portalService, ch);
+                } catch (LayoutException e) {
+                    throw new SAXException(e);
+                }
+                XMLUtils.endElement(ch, "coplet");
+            }
+            XMLUtils.endElement(ch, "coplets");
+        } else {
+            if ( StringUtils.isNotEmpty(copletId) ) {
+                XMLUtils.startElement(ch, "coplets");
+                final AttributesImpl a = new AttributesImpl();
+                a.addCDATAAttribute("id", copletId);
+                XMLUtils.startElement(ch, "coplet", a);
+            } else if ( StringUtils.isNotEmpty(layoutId) ) {
+                final AttributesImpl a = new AttributesImpl();
+                a.addCDATAAttribute("id", layoutId);
+                XMLUtils.startElement(ch, "layout", a);
+            }
+
+            // if no render parameter is specified we render the whole page or just the full screen coplet
+            if ( portalLayout == null ) {
+                // first check for a full screen layout
+                portalLayout = LayoutFeatures.getFullScreenInfo(this.portalService);
+                if ( portalLayout == null ) {
+                    portalLayout = profileManager.getLayout(null);
+                }
+            }
+
+            try {
+                final Renderer portalLayoutRenderer = this.portalService.getRenderer( this.portalService.getLayoutFactory().getRendererName(portalLayout));
+
+                portalLayoutRenderer.toSAX(portalLayout, this.portalService, ch);
+            } catch (LayoutException e) {
+                throw new SAXException(e);
+            }
+            if ( StringUtils.isNotEmpty(copletId) ) {
+                XMLUtils.endElement(ch, "coplet");
+                XMLUtils.endElement(ch, "coplets");
+            } else if ( StringUtils.isNotEmpty(layoutId) ) {
+                XMLUtils.endElement(ch, "layout");
+            }
+        }
+
+        ch.endDocument();
+        // although we should be the last in the queue,
+        // let's invoke the next
+        renderContext.invokeNext(ch, properties);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.PortalManager#register(org.apache.cocoon.portal.services.aspects.ResponseProcessorAspect)
+     */
+    public void register(ResponseProcessorAspect aspect) {
+        try {
+            this.responseChain.addAspect(aspect, null, 0);
+        } catch (PortalException pe) {
+            final IllegalArgumentException e = new IllegalArgumentException("Unable to add portal manager aspects.");
+            e.initCause(pe);
+            throw e;
+        }
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.PortalManager#register(org.apache.cocoon.portal.services.aspects.RequestProcessorAspect)
+     */
+    public void register(RequestProcessorAspect aspect) {
+        try {
+            this.responseChain.addAspect(aspect, null, 0);
+        } catch (PortalException pe) {
+            final IllegalArgumentException e = new IllegalArgumentException("Unable to add portal manager aspects.");
+            e.initCause(pe);
+            throw e;
+        }
+    }
+}

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultPortalManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultPortalManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: 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=diff&rev=511812&r1=511811&r2=511812
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ConstantParameterMatcher.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ConstantParameterMatcher.java Mon Feb 26 06:16:59 2007
@@ -1,34 +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);
-    }
+/*
+ * 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);
+    }
 }

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ConstantParameterMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ConstantParameterMatcher.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/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/links/DefaultLinkService.java?view=diff&rev=511812&r1=511811&r2=511812
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/DefaultLinkService.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/DefaultLinkService.java Mon Feb 26 06:16:59 2007
@@ -1,379 +1,379 @@
-/*
- * 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.event.EventConverter;
-import org.apache.cocoon.portal.event.EventManager;
-import org.apache.cocoon.portal.services.LinkService;
-import org.apache.cocoon.portal.services.aspects.RequestProcessorAspectContext;
-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 DefaultLinkService
-    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_EVENT_REQUEST_PARAMETER_NAME;
-
-    /**
-     * Construct a new link service.
-     */
-    public DefaultLinkService() {
-        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(DefaultLinkService.class.getName());
-        if ( info == null ) {
-            info = (LinkInfo)request.getAttribute(DefaultLinkService.class.getName());
-            if ( info == null ) {
-                info = new LinkInfo(request, this.defaultPort, this.defaultSecurePort);
-                request.setAttribute(DefaultLinkService.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();
-        // let's collect all events
-        final List allEvents = new ArrayList();
-
-        // 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;
-                    }
-                }
-                if ( !found ) {
-                    allEvents.add(current);
-                }
-            }
-        }
-
-        // add events
-        if ( info.events != null ) {
-            allEvents.addAll(info.events);
-        }
-
-        // now add supplied events and parameters
-        List parameterDescriptions = null;
-        final Iterator iter = events.iterator();
-        while (iter.hasNext()) {
-            final Object current = iter.next();
-            if (current instanceof Event) {
-                allEvents.add(current);
-            } else if ( current instanceof ParameterDescription ) {
-                if ( parameterDescriptions == null ) {
-                    parameterDescriptions = new ArrayList();
-                }
-                parameterDescriptions.add(current);
-            } else {
-                throw new PortalRuntimeException("Unknown object passed to create a link. Only events " +
-                            "and parameter descriptions are allowed. Unknown object: " + current);
-            }
-        }
-
-        return this.createUrl(allEvents, parameterDescriptions, secure);
-    }
-
-    /**
-     * @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();
-
-        // let's collect all events
-        final List allEvents = new ArrayList();
-        if ( info.comparableEvents != null ) {
-            allEvents.addAll(info.comparableEvents);
-        }
-        if ( info.events != null ) {
-            allEvents.addAll(info.events);
-        }
-        return this.createUrl(allEvents, null, secure);
-    }
-
-    /**
-     * @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;
-    }
-
-    protected String createUrl(List events, List parameterDescriptions, Boolean secure) {
-        final LinkInfo info = this.getInfo();
-
-        final StringBuffer buffer = new StringBuffer(info.getBase(secure));
-        boolean hasParams = buffer.indexOf("?") != -1;
-
-        // add events
-        final Iterator iter = 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 pIter = info.parameters.entrySet().iterator();
-            while ( pIter.hasNext() ) {
-                final Map.Entry current = (Map.Entry)pIter.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);
-                }
-            }
-        }
-        // add optional parameter descriptions
-        if ( parameterDescriptions != null ) {
-            final Iterator dIter = parameterDescriptions.iterator();
-            while ( dIter.hasNext() ) {
-                final ParameterDescription desc = (ParameterDescription)dIter.next();
-                if (hasParams) {
-                    buffer.append('&');
-                } else {
-                    buffer.append('?');
-                    hasParams = true;
-                }
-                buffer.append(desc.parameters);
-            }
-        }
-
-        return buffer.toString();
-    }
-
-    /**
-     * @see org.apache.cocoon.portal.services.aspects.RequestProcessorAspect#process(org.apache.cocoon.portal.services.aspects.RequestProcessorAspectContext)
-     */
-    public void process(RequestProcessorAspectContext context) {
-        final Request request = ObjectModelHelper.getRequest(context.getPortalService().getProcessInfoProvider().getObjectModel());
-        final EventManager publisher = context.getPortalService().getEventManager();
-        final EventConverter converter = context.getPortalService().getEventConverter();
-
-        final String[] values = request.getParameterValues( this.requestParameterName );
-        if ( values != null ) {
-            for(int i=0; i<values.length; i++) {
-                final String current = values[i];
-                final Event e = converter.decode(current);
-                if ( null != e) {
-                    publisher.send(e);
-                }
-            }
-        }
-        context.invokeNext();
-    }
-}
+/*
+ * 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.event.EventConverter;
+import org.apache.cocoon.portal.event.EventManager;
+import org.apache.cocoon.portal.services.LinkService;
+import org.apache.cocoon.portal.services.aspects.RequestProcessorAspectContext;
+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 DefaultLinkService
+    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_EVENT_REQUEST_PARAMETER_NAME;
+
+    /**
+     * Construct a new link service.
+     */
+    public DefaultLinkService() {
+        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(DefaultLinkService.class.getName());
+        if ( info == null ) {
+            info = (LinkInfo)request.getAttribute(DefaultLinkService.class.getName());
+            if ( info == null ) {
+                info = new LinkInfo(request, this.defaultPort, this.defaultSecurePort);
+                request.setAttribute(DefaultLinkService.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();
+        // let's collect all events
+        final List allEvents = new ArrayList();
+
+        // 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;
+                    }
+                }
+                if ( !found ) {
+                    allEvents.add(current);
+                }
+            }
+        }
+
+        // add events
+        if ( info.events != null ) {
+            allEvents.addAll(info.events);
+        }
+
+        // now add supplied events and parameters
+        List parameterDescriptions = null;
+        final Iterator iter = events.iterator();
+        while (iter.hasNext()) {
+            final Object current = iter.next();
+            if (current instanceof Event) {
+                allEvents.add(current);
+            } else if ( current instanceof ParameterDescription ) {
+                if ( parameterDescriptions == null ) {
+                    parameterDescriptions = new ArrayList();
+                }
+                parameterDescriptions.add(current);
+            } else {
+                throw new PortalRuntimeException("Unknown object passed to create a link. Only events " +
+                            "and parameter descriptions are allowed. Unknown object: " + current);
+            }
+        }
+
+        return this.createUrl(allEvents, parameterDescriptions, secure);
+    }
+
+    /**
+     * @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();
+
+        // let's collect all events
+        final List allEvents = new ArrayList();
+        if ( info.comparableEvents != null ) {
+            allEvents.addAll(info.comparableEvents);
+        }
+        if ( info.events != null ) {
+            allEvents.addAll(info.events);
+        }
+        return this.createUrl(allEvents, null, secure);
+    }
+
+    /**
+     * @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;
+    }
+
+    protected String createUrl(List events, List parameterDescriptions, Boolean secure) {
+        final LinkInfo info = this.getInfo();
+
+        final StringBuffer buffer = new StringBuffer(info.getBase(secure));
+        boolean hasParams = buffer.indexOf("?") != -1;
+
+        // add events
+        final Iterator iter = 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 pIter = info.parameters.entrySet().iterator();
+            while ( pIter.hasNext() ) {
+                final Map.Entry current = (Map.Entry)pIter.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);
+                }
+            }
+        }
+        // add optional parameter descriptions
+        if ( parameterDescriptions != null ) {
+            final Iterator dIter = parameterDescriptions.iterator();
+            while ( dIter.hasNext() ) {
+                final ParameterDescription desc = (ParameterDescription)dIter.next();
+                if (hasParams) {
+                    buffer.append('&');
+                } else {
+                    buffer.append('?');
+                    hasParams = true;
+                }
+                buffer.append(desc.parameters);
+            }
+        }
+
+        return buffer.toString();
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.services.aspects.RequestProcessorAspect#process(org.apache.cocoon.portal.services.aspects.RequestProcessorAspectContext)
+     */
+    public void process(RequestProcessorAspectContext context) {
+        final Request request = ObjectModelHelper.getRequest(context.getPortalService().getProcessInfoProvider().getObjectModel());
+        final EventManager publisher = context.getPortalService().getEventManager();
+        final EventConverter converter = context.getPortalService().getEventConverter();
+
+        final String[] values = request.getParameterValues( this.requestParameterName );
+        if ( values != null ) {
+            for(int i=0; i<values.length; i++) {
+                final String current = values[i];
+                final Event e = converter.decode(current);
+                if ( null != e) {
+                    publisher.send(e);
+                }
+            }
+        }
+        context.invokeNext();
+    }
+}

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/DefaultLinkService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/DefaultLinkService.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: 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=diff&rev=511812&r1=511811&r2=511812
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/LinkInfo.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/LinkInfo.java Mon Feb 26 06:16:59 2007
@@ -1,155 +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);
-            }
-        }
-    }
+/*
+ * 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$
+ */
+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);
+            }
+        }
+    }
 }

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/LinkInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/LinkInfo.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: 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=diff&rev=511812&r1=511811&r2=511812
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ParameterMatcher.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ParameterMatcher.java Mon Feb 26 06:16:59 2007
@@ -1,27 +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);
-
+/*
+ * 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);
+
 }

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ParameterMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/links/ParameterMatcher.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message