You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2005/08/30 13:11:20 UTC

svn commit: r264757 [1/4] - in /cocoon: blocks/portal/trunk/WEB-INF/xconf/ blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/ blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/ blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/co...

Author: cziegeler
Date: Tue Aug 30 04:10:28 2005
New Revision: 264757

URL: http://svn.apache.org/viewcvs?rev=264757&view=rev
Log:
Add WSRP Consumer support (through WSRP4J) to the portal block.

Added:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPAdapter.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEvent.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEventAspect.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/ConsumerEnvironmentImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/GroupSessionImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverRegistryImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletRegistryImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletSessionImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/ProducerDescription.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/ProducerRegistryImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/Request.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/RequestImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/RequiresConsumerEnvironment.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/RequiresPortalService.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/RequiresWSRPAdapter.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/SessionHandlerImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/SimplePortletWindowSession.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/SimplePortletWindowSessionImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLGeneratorImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLRewriterImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLTemplateComposerImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextExtension.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProvider.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProviderImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserRegistryImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserSessionImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/WSRPRequestImpl.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/logging/
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/logging/WSRPLogManager.java   (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/logging/WSRPLogger.java   (with props)
    cocoon/blocks/portal/trunk/samples/profiles/wsrp-config.xml   (with props)
    cocoon/blocks/portal/trunk/samples/skins/basic/css/wsrp.css   (with props)
    cocoon/blocks/portal/trunk/samples/skins/common/css/wsrp.css   (with props)
    cocoon/trunk/legal/wsrp4j-consumer-0.3-dev.jar.license.txt   (with props)
    cocoon/trunk/legal/wsrp4j-shared-0.3-dev.jar.license.txt   (with props)
    cocoon/trunk/lib/optional/wsrp4j-consumer-0.3-dev.jar   (with props)
    cocoon/trunk/lib/optional/wsrp4j-shared-0.3-dev.jar   (with props)
Modified:
    cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.samplesxconf
    cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.xconf
    cocoon/blocks/portal/trunk/samples/coplets/docs/portal-demo.xml
    cocoon/blocks/portal/trunk/samples/profiles/copletbasedata/portal.xml
    cocoon/blocks/portal/trunk/samples/profiles/copletdata/portal.xml
    cocoon/blocks/portal/trunk/samples/profiles/copletinstancedata/portal.xml
    cocoon/blocks/portal/trunk/samples/profiles/layout/portal.xml
    cocoon/blocks/portal/trunk/samples/sitemap-auth.xmap
    cocoon/blocks/portal/trunk/samples/sitemap.xmap
    cocoon/blocks/portal/trunk/samples/skins/basic/styles/portal-page.xsl
    cocoon/blocks/portal/trunk/samples/skins/common/styles/portal-page.xsl
    cocoon/blocks/portal/trunk/samples/skins/common/styles/window.xsl
    cocoon/trunk/gump.xml
    cocoon/trunk/lib/jars.xml
    cocoon/trunk/status.xml

Modified: cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.samplesxconf
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.samplesxconf?rev=264757&r1=264756&r2=264757&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.samplesxconf (original)
+++ cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.samplesxconf Tue Aug 30 04:10:28 2005
@@ -199,6 +199,25 @@
              <aspect type="coplet-cinclude"/>
          </aspects>
      </renderer>
+     <renderer name="wsrp-window"
+               class="org.apache.cocoon.portal.layout.renderer.impl.AspectRenderer"
+               logger="portal">
+         <aspects>
+             <aspect type="xslt">
+                 <parameter name="style" value="{portal-skin:skin.basepath}/styles/window.xsl"/>
+             </aspect>
+             <aspect type="parameter">
+                 <parameter name="tag-name" value="window"/>
+             </aspect>
+             <aspect type="wsrp-window">
+                 <parameter name="root-tag" value="false"/>
+             </aspect>
+             <aspect type="coplet-removing"/>
+             <aspect type="history"/>
+             <aspect type="basket"/>
+             <aspect type="coplet-cinclude"/>
+         </aspects>
+     </renderer>
      <renderer name="link" 
                class="org.apache.cocoon.portal.layout.renderer.impl.DefaultLinkRenderer" 
                logger="portal"/>

Modified: cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.xconf
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.xconf?rev=264757&r1=264756&r2=264757&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.xconf (original)
+++ cocoon/blocks/portal/trunk/WEB-INF/xconf/cocoon-portal.xconf Tue Aug 30 04:10:28 2005
@@ -54,6 +54,8 @@
 
     <!-- This aspect sets headers on the response that tell the client to not cache the response: -->
     <aspect logger="portal" name="no-client-caching" class="org.apache.cocoon.portal.event.aspect.impl.NoClientCachingEventAspect"/>
+    <!-- This aspect is required for wsrp: -->
+    <aspect logger="portal" name="wsrp" class="org.apache.cocoon.portal.wsrp.adapter.WSRPEventAspect"/>
   </component>
 
   <!-- Portal Manager Aspect Configuration -->
@@ -76,6 +78,8 @@
 	<!-- Uncomment the following when using PageLabels
         <aspect type="page-label"/>
         -->
+        <!-- Comment the following out if you don't need WSRP: -->
+        <aspect type="wsrp"/>
         <aspect type="request-parameter">
           <!-- Uncomment the following when marshalling JSR168 portlet events
           <parameter name="parameter-name" value="cocoon-portal-event,url"/>
@@ -105,12 +109,15 @@
        The portal manager can be extended with different aspects.
        Currently the JSR-168 aspect is configured/activated.
        If you don't need the JSR-168 support uncomment the aspect.
+       In a similar manner the wsrp support works.       
   -->
   <component class="org.apache.cocoon.portal.impl.PortalManagerImpl" 
              logger="portal" role="org.apache.cocoon.portal.PortalManager">
     <aspects>
       <!-- JSR-168 support: -->
       <aspect adapter="portlet"/>
+      <!-- wsrp support: -->
+      <aspect adapter="wsrp"/>
     </aspects>
   </component>
 
@@ -150,6 +157,13 @@
     <coplet-adapter name="application"
                     class="org.apache.cocoon.portal.coplet.adapter.impl.ApplicationCopletAdapter"
                     logger="portal"/>
+    <!-- This is the wsrp adapter -->
+    <coplet-adapter name="wsrp"
+                    class="org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter"
+                    logger="portal">
+      <!-- This is the wsrp configuration containing the producers etc. -->
+      <parameter name="wsrp-config" value="profiles/wsrp-config.xml"/>
+    </coplet-adapter>
   </component>
 
 
@@ -160,6 +174,8 @@
     <aspect logger="portal" name="window" class="org.apache.cocoon.portal.layout.renderer.aspect.impl.WindowAspect"/>
     <aspect logger="portal" name="portlet-window"
             class="org.apache.cocoon.portal.layout.renderer.aspect.impl.PortletWindowAspect"/>
+    <aspect logger="portal" name="wsrp-window"
+            class="org.apache.cocoon.portal.wsrp.adapter.WSRPPortletWindowAspect"/>
 
     <!-- This aspect can be used to render the minimize/maximize buttons -->
     <aspect logger="portal" name="coplet-sizing" class="org.apache.cocoon.portal.layout.renderer.aspect.impl.SizingAspect"/>
@@ -207,6 +223,12 @@
  <component class="org.apache.cocoon.portal.profile.impl.MapProfileLS" role="org.apache.cocoon.portal.profile.ProfileLS" logger="portal"/>
 
  <component class="org.apache.cocoon.components.variables.DefaultVariableResolverFactory" role="org.apache.cocoon.components.variables.VariableResolverFactory" logger="portal"/>
+
+ <!--  User Context Provider for WSRP -->
+ <component role="org.apache.cocoon.portal.wsrp.consumer.UserContextProvider"
+            class="org.apache.cocoon.portal.wsrp.consumer.UserContextProviderImpl"
+            logger="portal"/>
+
  <!-- This is the basket manager -->
  <component class="org.apache.cocoon.portal.coplets.basket.BasketManagerImpl" 
             role="org.apache.cocoon.portal.coplets.basket.BasketManager"

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPAdapter.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPAdapter.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPAdapter.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPAdapter.java Tue Aug 30 04:10:28 2005
@@ -0,0 +1,913 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed 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.wsrp.adapter;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.ServletConfig;
+
+import oasis.names.tc.wsrp.v1.types.BlockingInteractionResponse;
+import oasis.names.tc.wsrp.v1.types.MarkupContext;
+import oasis.names.tc.wsrp.v1.types.MarkupResponse;
+import oasis.names.tc.wsrp.v1.types.MarkupType;
+import oasis.names.tc.wsrp.v1.types.PortletContext;
+import oasis.names.tc.wsrp.v1.types.PortletDescription;
+import oasis.names.tc.wsrp.v1.types.SessionContext;
+import oasis.names.tc.wsrp.v1.types.UpdateResponse;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.environment.wrapper.RequestParameters;
+import org.apache.cocoon.portal.PortalManagerAspect;
+import org.apache.cocoon.portal.PortalManagerAspectPrepareContext;
+import org.apache.cocoon.portal.PortalManagerAspectRenderContext;
+import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.coplet.CopletData;
+import org.apache.cocoon.portal.coplet.CopletInstanceData;
+import org.apache.cocoon.portal.coplet.adapter.impl.AbstractCopletAdapter;
+import org.apache.cocoon.portal.coplet.status.SizingStatus;
+import org.apache.cocoon.portal.event.EventManager;
+import org.apache.cocoon.portal.event.Receiver;
+import org.apache.cocoon.portal.event.impl.ChangeCopletInstanceAspectDataEvent;
+import org.apache.cocoon.portal.event.impl.FullScreenCopletEvent;
+import org.apache.cocoon.portal.layout.Layout;
+import org.apache.cocoon.portal.serialization.IncludingHTMLSerializer;
+import org.apache.cocoon.portal.util.HtmlSaxParser;
+import org.apache.cocoon.portal.wsrp.consumer.ConsumerEnvironmentImpl;
+import org.apache.cocoon.portal.wsrp.consumer.ProducerDescription;
+import org.apache.cocoon.portal.wsrp.consumer.ProducerRegistryImpl;
+import org.apache.cocoon.portal.wsrp.consumer.Request;
+import org.apache.cocoon.portal.wsrp.consumer.RequestImpl;
+import org.apache.cocoon.portal.wsrp.consumer.RequiresConsumerEnvironment;
+import org.apache.cocoon.portal.wsrp.consumer.RequiresPortalService;
+import org.apache.cocoon.portal.wsrp.consumer.RequiresWSRPAdapter;
+import org.apache.cocoon.portal.wsrp.consumer.SimplePortletWindowSession;
+import org.apache.cocoon.portal.wsrp.consumer.UserContextProvider;
+import org.apache.cocoon.portal.wsrp.consumer.WSRPRequestImpl;
+import org.apache.cocoon.portal.wsrp.logging.WSRPLogManager;
+import org.apache.cocoon.portal.wsrp.logging.WSRPLogger;
+import org.apache.cocoon.servlet.CocoonServlet;
+import org.apache.cocoon.util.ClassUtils;
+import org.apache.cocoon.xml.AbstractXMLPipe;
+import org.apache.cocoon.xml.AttributesImpl;
+import org.apache.cocoon.xml.XMLUtils;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.wsrp4j.consumer.GroupSession;
+import org.apache.wsrp4j.consumer.PortletDriver;
+import org.apache.wsrp4j.consumer.PortletKey;
+import org.apache.wsrp4j.consumer.PortletSession;
+import org.apache.wsrp4j.consumer.Producer;
+import org.apache.wsrp4j.consumer.SessionHandler;
+import org.apache.wsrp4j.consumer.User;
+import org.apache.wsrp4j.consumer.UserSession;
+import org.apache.wsrp4j.consumer.WSRPPortlet;
+import org.apache.wsrp4j.consumer.driver.PortletKeyImpl;
+import org.apache.wsrp4j.consumer.driver.UserImpl;
+import org.apache.wsrp4j.consumer.driver.WSRPPortletImpl;
+import org.apache.wsrp4j.exception.ErrorCodes;
+import org.apache.wsrp4j.exception.WSRPException;
+import org.apache.wsrp4j.log.LogManager;
+import org.apache.wsrp4j.util.Constants;
+import org.apache.wsrp4j.util.WindowStates;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+
+/**
+ * Adapter to use wsrp-portlets as coplets <br/>
+ * It provides the wsrp support by initializing wsrp4j <br/>
+ * The aspect/adapter can be configured at the portal manager.<br/>
+ * 
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * @author <a href="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
+ *
+ * @version $Id$
+ */
+public class WSRPAdapter 
+    extends AbstractCopletAdapter
+    implements Contextualizable,
+               PortalManagerAspect,
+               Serviceable,
+               Initializable,
+               Disposable,
+               Parameterizable,
+               Receiver {
+
+    /** Key to store the consumer map into the coplet instance data object as a temporary attribute. */
+    public static final String ATTRIBUTE_NAME_CONSUMER_MAP = "wsrp-consumer-map";
+
+    /** Key to store the portlet instance key into the coplet instance data object as a temporary attribute. */
+    public static final String ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY = "wsrp-portlet-instance-key";
+
+    /** Key to store the portlet key into the coplet instance data objectt as a temporary attribute. */
+    public static final String ATTRIBUTE_NAME_PORTLET_KEY = "wsrp-portletkey";
+
+    /** Key to store the wsrp user into the coplet instance data object as a temporary attribute. */
+    public static final String ATTRIBUTE_NAME_USER = "wsrp-user";
+
+    /** Key to store the layout for the wsrp portlet into the coplet instance data object as a temporary attribute. */
+    public static final String ATTRIBUTE_NAME_LAYOUT = "wsrp-layout";
+
+    /** Key to store the wsrp title into the coplet instance data object as a temporary attribute. */
+    public static final String ATTRIBUTE_NAME_PORTLET_TITLE = "wsrp-title";
+
+    /** Key to store the wsrp modes into the coplet instance data object as a temporary attribute. */
+    public static final String ATTRIBUTE_NAME_PORTLET_MODES = "wsrp-modes";
+
+    /** Key to store the window states into the coplet instance data object as a temporary attribute. */
+    public static final String ATTRIBUTE_NAME_PORTLET_WINDOWSTATES = "wsrp-window-states";
+
+    /** Unique name of the consumer. */
+    public static final String CONSUMER_URL = "http://cocoon.apache.org/portal/wsrp-consumer";
+    
+    /** Name of the service. */
+    public static final String consumerAgent = "Apache Cocoon Portal." + org.apache.cocoon.Constants.VERSION;
+    
+    /** The avalon context. */
+    protected Context context;
+    
+    /** The consumer environment implementation. */
+    protected ConsumerEnvironmentImpl consumerEnvironment;
+    
+    /** Stores the current coplet instance data per thread. */
+    protected final ThreadLocal copletInstanceData = new InheritableThreadLocal();
+
+    /** The servlet configuration. */
+    protected ServletConfig servletConfig;
+
+    /** The service locator. */
+    protected ServiceManager manager;
+
+    /** The portal service. */
+    protected PortalService service;
+
+    /** The user context provider. */
+    protected UserContextProvider userContextProvider;
+
+    /** Location of the wsrp configuration. */
+    protected String wsrpConfigLocation;
+
+    /** Initialized? */
+    protected boolean initialized = false;
+
+    /** The wsrp configuration. */
+    protected Configuration wsrpConfiguration;
+
+    /** The configuration for this adapter. */
+    protected Parameters parameters;
+
+    /**
+     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+     */
+    public void contextualize(Context context) throws ContextException {
+        this.context = context;
+        try {
+            this.servletConfig = (ServletConfig) context.get(CocoonServlet.CONTEXT_SERVLET_CONFIG);
+            // we have to somehow pass this component down to other components!
+            // This is ugly, but it's the only chance for sofisticated component containers
+            // that wrap component implementations!
+            this.servletConfig.getServletContext().setAttribute(WSRPAdapter.class.getName(), this);
+        } catch (ContextException ignore) {
+            // we ignore the context exception
+            // this avoids startup errors if the portal is configured for the CLI
+            // environment
+            this.getLogger().warn("The wsrp support is disabled as the servlet context is not available.", ignore);
+        } 
+    }    
+
+    /**
+     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+        EventManager eventManager = null;
+        try {
+            eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
+            eventManager.subscribe(this);
+        } finally {
+            this.manager.release(eventManager);
+        }
+        this.service = (PortalService)this.manager.lookup(PortalService.ROLE);
+        this.userContextProvider = (UserContextProvider)this.manager.lookup(UserContextProvider.ROLE);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
+     */
+    public void parameterize(Parameters params) throws ParameterException {
+        this.wsrpConfigLocation = params.getParameter("wsrp-config");
+        this.parameters = params;
+    }
+
+    /**
+     * Sets the <tt>WSRPLogger</tt>, the <tt>producerConfig</tt> and the <tt>consumerEnvironment</tt><br/>
+     * 
+     * @see org.apache.avalon.framework.activity.Initializable#initialize()
+     */
+    public void initialize() throws Exception {
+        LogManager.setLogManager(new WSRPLogManager(new WSRPLogger(this.getLogger())));
+        this.consumerEnvironment = new ConsumerEnvironmentImpl();
+        this.consumerEnvironment.init(this.service, 
+                                      this);
+        consumerEnvironment.setConsumerAgent(consumerAgent);
+    }
+
+    /**
+     * Removes all portlets, producers and users out of the <tt>consumerEnvironment</tt>-registries<br/>
+     * 
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public void dispose() {
+        
+        consumerEnvironment.getPortletRegistry().removeAllPortlets();
+        
+        Iterator producers = consumerEnvironment.getProducerRegistry().getAllProducers();
+        Producer producer;
+        while (producers.hasNext()) {
+            producer = (Producer) producers.next();
+            try {
+                producer.deregister();    
+            } catch (WSRPException e) {
+                this.getLogger().error("deregister() producer: " + producer.getName());
+            }
+        }
+        consumerEnvironment.getProducerRegistry().removeAllProducers();
+        
+        consumerEnvironment.getUserRegistry().removeAllUsers();
+        
+        if ( this.manager != null ) {
+            EventManager eventManager = null;
+            try {
+                eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
+                eventManager.unsubscribe(this);
+            } catch (Exception ignore) {
+                // let's ignore it
+            } finally {
+                this.manager.release(eventManager);
+            }
+            this.manager.release(this.service);
+            this.manager.release(this.userContextProvider);
+            this.service = null;
+            this.userContextProvider = null;
+            this.manager = null;
+        }
+        try {
+            ContainerUtil.dispose(this.consumerEnvironment);
+            this.consumerEnvironment = null;
+        } catch (Throwable t) {
+            this.getLogger().error("Destruction failed!", t);
+        }
+        
+        if ( this.servletConfig != null ) {
+            this.servletConfig.getServletContext().removeAttribute(WSRPAdapter.class.getName());
+            this.servletConfig = null;
+        }
+    }
+
+    /**
+     * Gets the required information of the producer, user, wsrp-portlet, window-states, window-modes<br/>
+     * and stores its into the copletInstanceData<br/>
+     * After that it initiates the <tt>getServiceDescription()</tt>-call<br/>
+     * 
+     * @see org.apache.cocoon.portal.coplet.adapter.impl.AbstractCopletAdapter#login(org.apache.cocoon.portal.coplet.CopletInstanceData)
+     */
+    public void login(CopletInstanceData coplet) {
+        super.login(coplet);
+
+        final CopletData copletData = coplet.getCopletData();
+
+        // get the producer
+        final String producerId = (String) copletData.getAttribute("producer-id");
+        if ( producerId == null ) {
+            // if the producer can't be found, we simply return
+            this.getLogger().error("Producer not configured in wsrp coplet " + copletData.getId());
+            return;            
+        }
+        final Producer producer = consumerEnvironment.getProducerRegistry().getProducer(producerId);
+        if ( producer == null ) {
+            // if the producer can't be found, we simply return
+            this.getLogger().error("Producer with id " + producerId + " not found.");
+            return;
+        }
+
+        // get the wsrp user and store it as an attribute on the instance
+        final String currentUserID = this.service.getComponentManager().getProfileManager().getUser().getUserName();       
+        User user = this.consumerEnvironment.getUserRegistry().getUser(currentUserID);
+        if ( user == null ) {
+            // create a new user
+            user = new UserImpl(currentUserID);
+            user.setUserContext(this.userContextProvider.createUserContext(currentUserID));
+            this.consumerEnvironment.getUserRegistry().addUser(user);
+        }
+        coplet.setTemporaryAttribute(ATTRIBUTE_NAME_USER, user);
+
+        // get the portlet handle
+        final String portletHandle = (String) copletData.getAttribute("portlet-handle");
+        if ( portletHandle == null ) {
+            // if the portlet handle can't be found, we simply return
+            this.getLogger().error("Portlet handle not configured in wsrp coplet " + copletData.getId());
+            return;            
+        }
+
+        // get the wsrp portlet
+        final PortletKey portletKey = new PortletKeyImpl(portletHandle, producerId);
+        WSRPPortlet wsrpportlet = this.consumerEnvironment.getPortletRegistry().getPortlet(portletKey);
+        if ( wsrpportlet == null ) {
+            wsrpportlet = new WSRPPortletImpl(portletKey);
+            final PortletContext portletContext = new PortletContext(null, portletKey.getPortletHandle(), null);
+            wsrpportlet.setPortletContext(portletContext);
+            try {
+                consumerEnvironment.getPortletRegistry().addPortlet(wsrpportlet);
+            } catch (WSRPException we) {
+                this.getLogger().error("Exception adding wsrp portlet.", we);
+                return;
+            }
+        }
+        coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_KEY, portletKey);
+        final Session session = ObjectModelHelper.getRequest(this.service.getObjectModel()).getSession();
+        final String portletInstanceKey = this.getPortletInstanceKey(portletKey, coplet, session.getId());
+        coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY, portletInstanceKey);
+
+        // create consumer parameters
+        final Map addParams = new HashMap();
+        addParams.put(Constants.PORTLET_INSTANCE_KEY, portletInstanceKey);
+        coplet.setTemporaryAttribute(ATTRIBUTE_NAME_CONSUMER_MAP, addParams);
+
+        // get the window-state and -mode
+        SimplePortletWindowSession windowSession;
+        wsrpportlet = consumerEnvironment.getPortletRegistry().getPortlet(portletKey);
+
+        try {
+            // this call includes the getServiceDescription()-Invocation
+            // additionally register() initCookie() and so on will be handled 
+            // (within ProducerImpl and PortletDriverImpl)
+            windowSession = getSimplePortletWindowSession(wsrpportlet, 
+                                                          portletInstanceKey,
+                                                          user);
+            final PortletDescription desc = producer.getPortletDescription(portletHandle);
+            coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_TITLE,
+                                         desc.getTitle());
+            final MarkupType markupType = desc.getMarkupTypes(0);
+            coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_MODES, markupType.getModes());
+            coplet.setTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_WINDOWSTATES, markupType.getWindowStates());
+
+        } catch (WSRPException e) {
+            this.getLogger().error("Invoking getServiceDescription()", e);
+        }
+    }
+
+	/**
+     * Checks the values of the <tt>portlet-key</tt> and the <tt>user</tt> for current portlet-instance<br/>
+     * After that all passed the <tt>getMarkup()</tt>-call will be initiated<br />
+     * 
+	 * @see org.apache.cocoon.portal.coplet.adapter.impl.AbstractCopletAdapter#streamContent(org.apache.cocoon.portal.coplet.CopletInstanceData, org.xml.sax.ContentHandler)
+	 */
+	public void streamContent(CopletInstanceData coplet, ContentHandler contentHandler) 
+    throws SAXException {
+        try {
+            // set the coplet in the thread local variable to give other components access to
+            // the instance
+            this.setCurrentCopletInstanceData(coplet);
+
+            // get the portlet key and the user
+            final PortletKey portletKey = (PortletKey)coplet.getTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_KEY);
+            if ( portletKey == null ) {
+                throw new SAXException("WSRP configuration is missing: portlet key.");
+            }
+            final User user = (User)coplet.getTemporaryAttribute(ATTRIBUTE_NAME_USER);
+            if ( user == null ) {
+                throw new SAXException("WSRP configuration is missing: user.");
+            }
+            
+            final String portletInstanceKey = (String)coplet.getTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY);
+
+            // getMarkup()
+            final WSRPPortlet wsrpportlet = consumerEnvironment.getPortletRegistry().getPortlet(portletKey);
+
+            SimplePortletWindowSession windowSession = getSimplePortletWindowSession(wsrpportlet, portletInstanceKey, user);
+            final MarkupContext markupContext = this.getMarkupContext(wsrpportlet, windowSession, user);
+            if ( markupContext == null || markupContext.getMarkupString() == null ) {
+                throw new SAXException("No markup received from wsrp coplet " + coplet.getId());
+            }
+            final String content = markupContext.getMarkupString();
+
+            final Boolean usePipeline;
+            final boolean usesGet;
+            // If the portlet uses the method get we always have to rewrite form elements
+            final Producer producer = this.consumerEnvironment.getProducerRegistry().getProducer(portletKey.getProducerId());
+            final PortletDescription desc = producer.getPortletDescription(portletKey.getPortletHandle());
+            if ( desc.getUsesMethodGet() != null && desc.getUsesMethodGet().booleanValue() ) {
+                usePipeline = Boolean.TRUE;
+                usesGet = true;
+            } else {
+                usePipeline = (Boolean)this.getConfiguration(coplet, "use-pipeline", Boolean.FALSE);
+                usesGet = false;
+            }
+            if ( usePipeline.booleanValue() ) {
+                if ( usesGet ) {
+                    contentHandler = new FormRewritingHandler(contentHandler);
+                }
+                HtmlSaxParser.parseString(content, contentHandler);
+            } else {
+                // stream out the include for the serializer
+                IncludingHTMLSerializer.addPortlet(portletInstanceKey, content);
+                contentHandler.startPrefixMapping("portal", IncludingHTMLSerializer.NAMESPACE);
+                final AttributesImpl attr = new AttributesImpl();
+                attr.addCDATAAttribute("portlet", portletInstanceKey);
+                contentHandler.startElement(IncludingHTMLSerializer.NAMESPACE,
+                                            "include",
+                                            "portal:include",
+                                            attr);
+                contentHandler.endElement(IncludingHTMLSerializer.NAMESPACE,
+                                          "include",
+                                          "portal:include");
+                contentHandler.endPrefixMapping("portal");
+            }
+        } catch (WSRPException e) {
+            throw new SAXException("Exception during getMarkup of wsrp coplet: " + coplet.getId(), e);
+        } catch (SAXException se) {
+            throw se;
+        } finally {
+            this.setCurrentCopletInstanceData(null);
+        }
+	}
+    
+    /**
+     * Releases all sessions (<tt>userSession, groupSession, portletSession</tt>)<br/>
+     * 
+     * @see org.apache.cocoon.portal.coplet.adapter.impl.AbstractCopletAdapter#logout(org.apache.cocoon.portal.coplet.CopletInstanceData)
+     */
+    public void logout(CopletInstanceData coplet) {
+    	super.logout(coplet);
+
+        PortletKey portletKey = (PortletKey)coplet.getTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_KEY);
+        User user = (User)coplet.getTemporaryAttribute(ATTRIBUTE_NAME_USER);
+        final String portletInstanceKey = (String)coplet.getTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY);
+        Producer producer = consumerEnvironment.getProducerRegistry().getProducer(portletKey.getProducerId());
+        
+        // releaseSession()
+        try {
+            UserSession userSession = consumerEnvironment.getSessionHandler().getUserSession(portletKey.getProducerId(), user.getUserID());
+            PortletDescription portletDescription = producer.getPortletDescription(portletKey.getPortletHandle());
+            GroupSession groupSession = userSession.getGroupSession(portletDescription.getGroupID());
+            PortletSession portletSession = groupSession.getPortletSession(portletInstanceKey);
+            SessionContext sessionContext = portletSession.getSessionContext();
+            WSRPPortlet wsrpportlet = consumerEnvironment.getPortletRegistry().getPortlet(portletKey);
+            PortletDriver portletDriver = consumerEnvironment.getPortletDriverRegistry().getPortletDriver(wsrpportlet);
+    
+            if (sessionContext != null) {
+                String[] sessions = new String[1];
+                sessions[0] = new String (sessionContext.getSessionID());
+                portletDriver.releaseSessions(sessions, user.getUserID());
+            }
+            
+            userSession.removeGroupSession(portletDescription.getGroupID());
+        } catch (WSRPException e) {
+            this.getLogger().error("session deregister()", e);
+        }
+    }
+    
+    /**
+     * After getting the <tt>userSession</tt> and <tt>groupSession</tt> it performs the <tt>getServiceDescription()</tt>-call<br/>
+     *  
+     * @param portlet
+     * @param portletInstanceKey
+     * @param user
+     * @return SimplePortletWindowSession
+     * @throws WSRPException
+     */
+    public SimplePortletWindowSession getSimplePortletWindowSession(WSRPPortlet portlet, 
+                                                                    String portletInstanceKey,
+                                                                    User user)
+    throws WSRPException {
+        SimplePortletWindowSession windowSession = null;
+
+        // get the user session
+        SessionHandler sessionHandler = consumerEnvironment.getSessionHandler();
+        UserSession userSession = sessionHandler.getUserSession(portlet.getPortletKey().getProducerId(), user.getUserID());
+
+        if (userSession != null) {
+            // get the group session
+            String groupID = null;
+            try {
+                Producer producer = consumerEnvironment.getProducerRegistry().getProducer(portlet.getPortletKey().getProducerId());
+                // *********************************
+                // getServiceDescription()
+                // *********************************
+                PortletDescription portletDescription = producer.getPortletDescription(portlet.getPortletKey().getPortletHandle());
+
+                if (portletDescription != null) {
+                    groupID = portletDescription.getGroupID();
+                }
+            } catch (WSRPException e) {
+                groupID = "default_group_id";
+                this.getLogger().info("using default-group");
+            }
+
+            GroupSession groupSession = userSession.getGroupSession(groupID);
+
+            if (groupSession != null) {
+                PortletSession portletSession = groupSession.getPortletSession(portlet.getPortletKey().getPortletHandle());
+
+                if (portletSession != null) {
+                    windowSession = (SimplePortletWindowSession) portletSession.getPortletWindowSession(portletInstanceKey);
+                } else {
+                    this.getLogger().error("WSRP-Errorcode: " + Integer.toString(ErrorCodes.PORTLET_SESSION_NOT_FOUND));
+                }
+            } else {
+                this.getLogger().error("WSRP-Errorcode: " + Integer.toString(ErrorCodes.GROUP_SESSION_NOT_FOUND));
+            }
+        } else {
+            this.getLogger().error("WSRP-Errorcode: " + Integer.toString(ErrorCodes.USER_SESSION_NOT_FOUND));
+        }
+        return windowSession;
+    }
+
+    /**
+     * Performs an blocking interaction with the given portlet and session.<br/>
+     * If the response to this call is a redirect URL's it won't be followed.<br/>
+     * 
+     * An optionally returned markup context is store in the window session<br/>
+     * and should be processed by the portlet driver instead of making a new<br/>
+     * getMarkup() call.<br/>
+     * 
+     * @param portlet The portlet on which this action should be performed
+     * @param windowSession The window session of the portlet on which the action should
+     *        be performed
+     * @param user The user on which this action should be performed
+     * @param request The request with all required information for the call
+     **/
+    protected void performBlockingInteraction(WSRPPortlet portlet, 
+                                              SimplePortletWindowSession windowSession,
+                                              User user,
+                                              Request request) {
+        try {
+            PortletDriver portletDriver = consumerEnvironment.getPortletDriverRegistry().getPortletDriver(portlet);
+            BlockingInteractionResponse response = portletDriver.performBlockingInteraction(
+                    new WSRPRequestImpl(windowSession, request, consumerEnvironment), user.getUserID());
+
+            if (response != null) {
+                UpdateResponse update = response.getUpdateResponse();
+                if (update != null) {
+                    //update the WSRP portlet sessionContext
+                    windowSession.getPortletSession().setSessionContext(update.getSessionContext());
+
+                    MarkupContext markupContext = update.getMarkupContext();
+                    if (markupContext != null) {
+                        windowSession.updateMarkupCache(markupContext);
+                    }
+
+                    windowSession.setNavigationalState(update.getNavigationalState());
+
+                    String windowState = null;
+                    if ((windowState = update.getNewWindowState()) != null) {
+                        windowSession.setWindowState(windowState);
+                    }
+
+                    String windowMode = null;
+                    if ((windowMode = update.getNewMode()) != null) {
+                        windowSession.setMode(windowMode);
+                    }
+                } else if (response.getRedirectURL() != null) {
+                    this.getLogger().debug("response.getRedirectURL() != null");
+                }
+            }
+        } catch (WSRPException e) {
+            this.getLogger().error("Error occured during performInteraction!", e);
+        }
+    }
+
+    /**
+     * Retrieves the markup generated by the portlet.
+     * 
+     * @param portlet
+     * @param windowSession
+     * @param user
+     * @return The markup context.
+     **/
+    protected MarkupContext getMarkupContext(WSRPPortlet portlet,
+                                             SimplePortletWindowSession windowSession,
+                                             User user)
+    throws WSRPException {
+        WSRPRequestImpl wsrpRequest = new WSRPRequestImpl(windowSession, null, this.consumerEnvironment);
+
+        PortletDriver portletDriver = consumerEnvironment.getPortletDriverRegistry().getPortletDriver(portlet);
+        MarkupResponse response = portletDriver.getMarkup(wsrpRequest, user.getUserID());
+
+        if (response != null) {
+            SessionContext sessionContext = response.getSessionContext();
+            if (sessionContext != null && windowSession != null) {
+                windowSession.getPortletSession().setSessionContext(sessionContext);
+            }
+
+            return response.getMarkupContext();
+        }
+        return null;
+    }
+
+    /**
+     * Creates a <tt>String</tt> consists of the producer-id_portlet-handle_coplet-id_user-name <br/>
+     * 
+     * @param key includes the essential values
+     * @param coplet current <tt>CopletInstanceData</tt>-object
+     * @param userName
+     * @return the unique string which represents the portlet-instance 
+     * */
+    protected String getPortletInstanceKey(PortletKey key, 
+                                           CopletInstanceData coplet,
+                                           String userName) {
+        final StringBuffer buffer = new StringBuffer(key.getProducerId());
+        buffer.append('_').append(key.getPortletHandle()).append('_');
+        buffer.append(coplet.getId()).append('_').append(userName);
+        return buffer.toString();    
+    }
+    
+    /**
+     * Gets all required information like <tt>portletKey, portletInstanceKey, userName, portletModes, windowStates, 
+     * interactionState</tt> and the <tt>navigationalStat</tt><br/>
+     * 
+     * After that it decides with the <tt>URL_TYPE</tt> to perform the <tt>performBlockingInteraction()</tt>-call or
+     * do some render- alternatively some resource-specific things<br/>
+     * 
+     * @see Receiver
+     */
+    public void inform(WSRPEvent event, PortalService service) {
+        final CopletInstanceData coplet = (CopletInstanceData)event.getTarget();
+        this.setCurrentCopletInstanceData(coplet);
+        
+        try {
+            PortletKey portletKey = (PortletKey)coplet.getTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_KEY);
+            final String portletInstanceKey = (String)coplet.getTemporaryAttribute(ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY);
+            WSRPPortlet wsrpPortlet = consumerEnvironment.getPortletRegistry().getPortlet(portletKey);
+            User user = (User) coplet.getTemporaryAttribute(ATTRIBUTE_NAME_USER);
+            
+            org.apache.cocoon.environment.Request requestObject = ObjectModelHelper.getRequest(service.getObjectModel());
+            java.util.Enumeration formParameter = requestObject.getParameterNames();
+
+            Request request = new RequestImpl();
+            String portletMode = requestObject.getParameter(Constants.PORTLET_MODE);
+            String windowState = requestObject.getParameter(Constants.WINDOW_STATE);
+            
+            request.setInteractionState(requestObject.getParameter(Constants.INTERACTION_STATE));
+            SimplePortletWindowSession windowSession = getSimplePortletWindowSession(wsrpPortlet, portletInstanceKey, user);
+            windowSession.setNavigationalState(requestObject.getParameter(Constants.NAVIGATIONAL_STATE));
+
+            if (portletMode != null) {
+                windowSession.setMode(portletMode);
+            }
+            if (windowState != null) {
+                if ( !windowState.equals(windowSession.getWindowState()) ) {
+                    final Layout layout = (Layout)coplet.getTemporaryAttribute(ATTRIBUTE_NAME_LAYOUT);
+                    final Layout fullScreenLayout = service.getEntryLayout(null);
+                    if ( fullScreenLayout != null 
+                         && fullScreenLayout.equals( layout )
+                         && !windowState.equals(WindowStates._maximized) ) {
+                        FullScreenCopletEvent e = new FullScreenCopletEvent( coplet, null );
+                        service.getComponentManager().getEventManager().send(e);
+                    }
+                    if ( windowState.equals(WindowStates._minimized) ) {
+                        ChangeCopletInstanceAspectDataEvent e = new ChangeCopletInstanceAspectDataEvent(coplet, "size", SizingStatus.STATUS_MINIMIZED);
+                        service.getComponentManager().getEventManager().send(e);
+                    }
+                    if ( windowState.equals(WindowStates._normal) ) {
+                        ChangeCopletInstanceAspectDataEvent e = new ChangeCopletInstanceAspectDataEvent(coplet, "size", SizingStatus.STATUS_MAXIMIZED);
+                        service.getComponentManager().getEventManager().send(e);
+                    }
+                    if ( windowState.equals(WindowStates._maximized) ) {
+                        FullScreenCopletEvent e = new FullScreenCopletEvent( coplet, layout );
+                        service.getComponentManager().getEventManager().send(e);
+                    }
+                    windowSession.setWindowState(windowState);
+                }
+            }
+            if (requestObject.getParameter(Constants.URL_TYPE).equals(Constants.URL_TYPE_BLOCKINGACTION)) {
+            // performBlockingInteraction()
+                String parameter;
+                while (formParameter.hasMoreElements()) {
+                    parameter = (String) formParameter.nextElement();
+                    request.addFormParameter(parameter, requestObject.getParameter(parameter));
+                }
+                performBlockingInteraction(wsrpPortlet, windowSession, user, request);
+            
+            }
+                
+        } catch (WSRPException e) {
+            this.getLogger().error("Error during processing wsrp event.", e);
+        } finally {
+            this.setCurrentCopletInstanceData(null);
+        }
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.PortalManagerAspect#prepare(org.apache.cocoon.portal.PortalManagerAspectPrepareContext, org.apache.cocoon.portal.PortalService)
+     */
+    public void prepare(PortalManagerAspectPrepareContext aspectContext,
+                        PortalService service)
+    throws ProcessingException {
+        // process the events
+        aspectContext.invokeNext();
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.PortalManagerAspect#render(org.apache.cocoon.portal.PortalManagerAspectRenderContext, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler, org.apache.avalon.framework.parameters.Parameters)
+     */
+    public void render(PortalManagerAspectRenderContext aspectContext,
+                       PortalService service,
+                       ContentHandler ch,
+                       Parameters parameters)
+    throws SAXException {
+        aspectContext.invokeNext(ch, parameters);
+    }
+
+    /**
+     * @return Returns the <tt>consumerEnvironmentImpl</tt>
+     */
+    public ConsumerEnvironmentImpl getConsumerEnvironment() {
+        return consumerEnvironment;
+    }
+
+    /**
+     * Add a new producer<br/>
+     * 
+     * @param desc The producer description.
+     * @return Returns true if the producer could be added.
+     */
+    public boolean addProducer(ProducerDescription desc) {
+        return ((ProducerRegistryImpl)this.consumerEnvironment.getProducerRegistry()).addProducer(desc);
+    }
+
+    /**
+     * This sets the current coplet instance data for the thread <br/>
+     * 
+     * @param coplet The coplet instance data or null to clear the information.
+     */
+    public void setCurrentCopletInstanceData(CopletInstanceData coplet) {
+        this.copletInstanceData.set(coplet);
+    }
+
+    /**
+     * Return the current coplet instance data<br/>
+     * 
+     * @return Returns the instance or null.
+     */
+    public CopletInstanceData getCurrentCopletInstanceData() {
+        return (CopletInstanceData)this.copletInstanceData.get();
+    }
+
+    /**
+     * This handler is triggered by a form element. It rewrites the
+     * action if the method get is used. In this case all request parameters
+     * of the action are added as hidden fields.
+     */
+    public static final class FormRewritingHandler extends AbstractXMLPipe {
+
+        public FormRewritingHandler(ContentHandler ch) {
+            this.setContentHandler(ch);
+            if ( ch instanceof LexicalHandler ) {
+                this.setLexicalHandler((LexicalHandler)ch);
+            }
+        }
+
+        /**
+         * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
+         */
+        public void startElement(String uri, String loc, String raw, Attributes a) throws SAXException {
+            if ( loc.equalsIgnoreCase("form") && a.getValue("method").equalsIgnoreCase("get") ) {
+                final String action = a.getValue("action");
+                int pos = action.indexOf('?');
+                if ( pos != -1 ) {
+                    AttributesImpl ai = new AttributesImpl(a);
+                    a = ai;
+                    final String queryString = action.substring(pos+1);
+                    ai.removeAttribute("action");
+                    ai.addCDATAAttribute("action", action.substring(0, pos));
+                    super.startElement(uri, loc, raw, a);
+                    RequestParameters rp = new RequestParameters(queryString);
+
+                    final Enumeration e = rp.getParameterNames();
+                    while ( e.hasMoreElements() ) {
+                        final String key = (String)e.nextElement();
+                        final String value = rp.getParameter(key);
+                        AttributesImpl attributes = new AttributesImpl();
+                        attributes.addCDATAAttribute("type", "hidden");
+                        attributes.addCDATAAttribute("name", key);
+                        attributes.addCDATAAttribute("value", value);
+                        XMLUtils.createElement(this.contentHandler, "input", attributes);
+                    }
+                    return;
+                }
+            }
+            super.startElement(uri, loc, raw, a);
+        }
+
+    }
+
+    /**
+     * Check if we have read our configuration already.
+     * If not, read the config and invoke the configure method.
+     */
+    protected void checkInitialized() {
+        if ( !this.initialized ) {
+            synchronized (this) {
+                if (! this.initialized ) {
+                    this.initialized = true;
+                    SourceResolver resolver = null;
+                    Source source = null;
+                    try {
+                        resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
+                        source = resolver.resolveURI(this.wsrpConfigLocation);
+                        DefaultConfigurationBuilder dcb = new DefaultConfigurationBuilder();
+                        this.wsrpConfiguration = dcb.build(source.getInputStream());
+                    } catch (ConfigurationException ce) {
+                        this.getLogger().error("Unable to read wsrp configuration: " + this.wsrpConfigLocation, ce);
+                    } catch (IOException ioe) {
+                        this.getLogger().error("Unable to read wsrp configuration: " + this.wsrpConfigLocation, ioe);
+                    } catch (SAXException sae) {
+                        this.getLogger().error("Unable to read wsrp configuration: " + this.wsrpConfigLocation, sae);
+                    } catch (ServiceException se) {
+                        throw new RuntimeException("Unable to get source resolver.", se);
+                    } finally {
+                        if ( resolver != null ) {
+                            resolver.release(source);
+                        }
+                        this.manager.release(resolver);
+                    }            
+                }
+            }
+        }
+    }
+
+    /**
+     * Get the wsrp configuration.
+     */
+    public Configuration getWsrpConfiguration() {
+        this.checkInitialized();
+        return this.wsrpConfiguration;
+    }
+
+    /**
+     * Get the adapter configuration.
+     */
+    public Parameters getAdapterConfiguration() {
+        return this.parameters;
+    }
+
+    /**
+     * Create a component.
+     */
+    public Object createObject(String className)
+    throws Exception {
+        final Object component = ClassUtils.newInstance(className);
+        ContainerUtil.enableLogging(component, this.getLogger());
+        if (component instanceof RequiresConsumerEnvironment) {
+            ((RequiresConsumerEnvironment)component).setConsumerEnvironment(this.consumerEnvironment);
+        }
+        if (component instanceof RequiresWSRPAdapter) {
+            ((RequiresWSRPAdapter)component).setWSRPAdapter(this);
+        }
+        if (component instanceof RequiresPortalService) {
+            ((RequiresPortalService)component).setPortalService(this.service);
+        }
+        ContainerUtil.contextualize(component, context);
+        ContainerUtil.service(component, manager);
+        ContainerUtil.initialize(component);
+
+        return component;
+    }
+
+}

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEvent.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEvent.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEvent.java Tue Aug 30 04:10:28 2005
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.wsrp.adapter;
+
+import java.util.Map;
+
+import org.apache.cocoon.portal.coplet.CopletInstanceData;
+import org.apache.cocoon.portal.event.CopletInstanceEvent;
+
+/**
+ * This event is fired for every wsrp action. <br/>
+ * 
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * @author <a href="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
+ * 
+ * @version $Id$
+ */
+public class WSRPEvent
+    implements CopletInstanceEvent {
+
+    /** The corresponding coplet instance data. */
+    protected final CopletInstanceData coplet;
+
+    /** The parameters for the wsrp url. */
+    protected final Map producerParams;
+
+    /**
+     * constructor
+     * 
+     * @param coplet corresponding coplet instance data
+     * @param pParams producer-parameters
+     */
+    public WSRPEvent(CopletInstanceData coplet, Map pParams) {
+        this.coplet = coplet;
+        this.producerParams = pParams;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.event.ActionEvent#getTarget()
+     */
+    public Object getTarget() {
+        return this.coplet;
+    }
+
+    /**
+     * @return Map all parameters for the wsrp url.
+     */
+    public Map getUrlParameters() {
+        return this.producerParams;
+    }
+
+}

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEvent.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEventAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEventAspect.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEventAspect.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEventAspect.java Tue Aug 30 04:10:28 2005
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.wsrp.adapter;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.coplet.CopletInstanceData;
+import org.apache.cocoon.portal.event.Event;
+import org.apache.cocoon.portal.event.aspect.EventAspect;
+import org.apache.cocoon.portal.event.aspect.EventAspectContext;
+
+/**
+ * This event processes all wsrp related urls and fires {@link org.apache.cocoon.portal.wsrp.adapter.WSRPEvent}s.
+ *
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * @author <a href="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
+ * 
+ * @version $Id$
+ */
+public class WSRPEventAspect implements EventAspect {
+
+    public static final String REQUEST_PARAMETER_NAME = "cocoon-wsrpevent";
+
+    /**
+     * @see org.apache.cocoon.portal.event.aspect.EventAspect#process(org.apache.cocoon.portal.event.aspect.EventAspectContext, org.apache.cocoon.portal.PortalService)
+     */
+    public void process(EventAspectContext context, PortalService service) {
+        final Request request = ObjectModelHelper.getRequest(context.getObjectModel());
+        final String[] values = request.getParameterValues("cocoon-wsrpevent");
+        if ( values != null && values.length == 1 ) {
+            // create a wsrp event, first build map of parameters
+            final Map parameters = new HashMap();
+            final Enumeration parameterNames = request.getParameterNames();
+            while ( parameterNames.hasMoreElements() ) {
+                final String name = (String)parameterNames.nextElement();
+                if ( !REQUEST_PARAMETER_NAME.equals(name) ) {
+                    final String value = request.getParameter(name);
+                    parameters.put(name, value);
+                }
+            }
+            final String copletid = values[0];
+            final CopletInstanceData cid = service.getComponentManager().getProfileManager().getCopletInstanceData(copletid);
+
+            final Event e = new WSRPEvent(cid, parameters);
+            service.getComponentManager().getEventManager().send(e);
+        }
+        context.invokeNext(service);
+    }
+}

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEventAspect.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEventAspect.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java Tue Aug 30 04:10:28 2005
@@ -0,0 +1,326 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.wsrp.adapter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.ServletConfig;
+
+import oasis.names.tc.wsrp.v1.types.LocalizedString;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.portal.LinkService;
+import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.coplet.CopletInstanceData;
+import org.apache.cocoon.portal.event.Event;
+import org.apache.cocoon.portal.event.impl.ChangeCopletInstanceAspectDataEvent;
+import org.apache.cocoon.portal.layout.Layout;
+import org.apache.cocoon.portal.layout.impl.CopletLayout;
+import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
+import org.apache.cocoon.portal.layout.renderer.aspect.impl.AbstractAspect;
+import org.apache.cocoon.portal.wsrp.consumer.ConsumerEnvironmentImpl;
+import org.apache.cocoon.portal.wsrp.consumer.SimplePortletWindowSession;
+import org.apache.cocoon.servlet.CocoonServlet;
+import org.apache.cocoon.xml.XMLUtils;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.wsrp4j.consumer.PortletKey;
+import org.apache.wsrp4j.consumer.URLGenerator;
+import org.apache.wsrp4j.consumer.User;
+import org.apache.wsrp4j.consumer.WSRPPortlet;
+import org.apache.wsrp4j.exception.WSRPException;
+import org.apache.wsrp4j.util.Constants;
+import org.apache.wsrp4j.util.Modes;
+import org.apache.wsrp4j.util.WindowStates;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * This aspect draws a portlet window for a wsrp portlet.
+ * 
+ * <h2>Example XML:</h2>
+ * <pre>
+ *   &lt;window&gt;
+ *     &lt;title&gt;title&lt;/title&gt;
+ *     &lt;maximize-uri&gt;event&lt;/maximize-uri&gt;
+ *     &lt;minimize-uri&gt;event&lt;/minimize-uri&gt;
+ *     &lt;fullscreen-uri&gt;event&lt;/fullscreen-uri&gt;
+ *     &lt;edit-uri&gt;event&lt;/edit-uri&gt;
+ *     &lt;help-uri&gt;event&lt;/help-uri&gt;
+ *     &lt;view-uri&gt;event&lt;/view-uri&gt;
+ *     &lt;!-- output of following renderers --&gt;
+ *   &lt;/window&gt;
+ * </pre>
+ * 
+ * <h2>Applicable to:</h2>
+ * <ul>
+ *  <li>{@link org.apache.cocoon.portal.layout.impl.CopletLayout}</li>
+ * </ul>
+ * 
+ * <h2>Parameters</h2>
+ * <table><tbody>
+ * <tr><th>root-tag</th><td>Should a root tag surrounding the following output
+ *  be generated?</td><td></td><td>boolean</td><td><code>true</code></td></tr>
+ * <tr><th>tag-name</th><td>Name of the root tag if requested.
+ *  </td><td></td><td>String</td><td><code>"window"</code></td></tr>
+ * </tbody></table>
+ * 
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * @author <a href="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
+ * 
+ * @version $Id$
+ */
+public final class WSRPPortletWindowAspect 
+extends AbstractAspect
+    implements Contextualizable {
+
+    /** The environment implementation*/
+    protected ConsumerEnvironmentImpl environment;
+
+    /** The wsrp adapter. */
+    protected WSRPAdapter adapter;
+
+    /**
+     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+     */
+    public void contextualize(Context context) throws ContextException {
+        try {
+            // now get the wsrp adapter
+            ServletConfig servletConfig = (ServletConfig) context.get(CocoonServlet.CONTEXT_SERVLET_CONFIG);
+            this.adapter = (WSRPAdapter)servletConfig.getServletContext().getAttribute(WSRPAdapter.class.getName());
+            if ( this.adapter != null ) {
+                this.environment = this.adapter.getConsumerEnvironment();
+            }
+        } catch (ContextException ignore) {
+            // we ignore the context exception
+            // this avoids startup errors if the portal is configured for the CLI
+            // environment
+            this.getLogger().warn("The wsrp support is disabled as the servlet context is not available.", ignore);
+        }
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.layout.renderer.aspect.RendererAspect#toSAX(org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext, org.apache.cocoon.portal.layout.Layout, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler)
+     */
+    public void toSAX(RendererAspectContext context,
+                      Layout layout,
+                      PortalService service,
+                      ContentHandler contenthandler)
+    throws SAXException {
+        final PreparedConfiguration config = (PreparedConfiguration)context.getAspectConfiguration();
+        final CopletInstanceData copletInstanceData = ((CopletLayout)layout).getCopletInstanceData();
+
+        if ( config.rootTag ) {
+            XMLUtils.startElement(contenthandler, config.tagName);
+        }
+        final PortletKey portletKey = (PortletKey)copletInstanceData.getTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_PORTLET_KEY);
+
+        if ( portletKey == null ) {
+            // no portlet window, so use a default behaviour
+            XMLUtils.createElement(contenthandler, "title", copletInstanceData.getTitle());
+        } else {
+            copletInstanceData.setTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_LAYOUT, layout);
+            LocalizedString localizedTitle = (LocalizedString)copletInstanceData.getTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_PORTLET_TITLE);
+            String title;
+            if ( localizedTitle == null ) {
+                title = copletInstanceData.getTitle();
+            } else {
+                title = localizedTitle.getValue();
+            }
+            XMLUtils.createElement(contenthandler, "title", title);            
+
+            final String portletInstanceKey = (String)copletInstanceData.getTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_PORTLET_INSTANCE_KEY);
+            final User user = (User)copletInstanceData.getTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_USER);
+
+            final WSRPPortlet portlet = this.environment.getPortletRegistry().getPortlet(portletKey);
+            try {
+                SimplePortletWindowSession windowSession = this.adapter.getSimplePortletWindowSession(portlet, portletInstanceKey, user);
+                if ( this.environment != null && windowSession != null ) {
+                    this.adapter.setCurrentCopletInstanceData(copletInstanceData);
+                    URLGenerator urlGenerator = this.environment.getURLGenerator();
+
+                    String[] supportedWindowStates = (String[])copletInstanceData.getTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_PORTLET_WINDOWSTATES);
+                    String ws = windowSession.getWindowState();
+                    if ( ws == null ) {
+                        ws = WindowStates._normal;
+                    }
+
+                    if ( !ws.equals(WindowStates._minimized) 
+                         && ArrayUtils.contains(supportedWindowStates, WindowStates._minimized)) {
+                        final Map p = new HashMap();
+                        p.put(Constants.URL_TYPE, Constants.URL_TYPE_RENDER);
+                        p.put(Constants.WINDOW_STATE, WindowStates._minimized);
+                        
+                        final String link = urlGenerator.getRenderURL(p);
+                        XMLUtils.createElement(contenthandler, "minimize-uri", link);
+                    }
+                    if ( !ws.equals(WindowStates._normal)
+                          && ArrayUtils.contains(supportedWindowStates, WindowStates._normal)) {
+                        final Map p = new HashMap();
+                        p.put(Constants.URL_TYPE, Constants.URL_TYPE_RENDER);
+                        p.put(Constants.WINDOW_STATE, WindowStates._normal);
+
+                        final String link = urlGenerator.getRenderURL(p);
+                        XMLUtils.createElement(contenthandler, "maximize-uri", link);
+                    } 
+                    if ( !ws.equals(WindowStates._maximized)
+                          && ArrayUtils.contains(supportedWindowStates, WindowStates._maximized)) {
+                        final Map p = new HashMap();
+                        p.put(Constants.URL_TYPE, Constants.URL_TYPE_RENDER);
+                        p.put(Constants.WINDOW_STATE, WindowStates._maximized);
+
+                        final String link = urlGenerator.getRenderURL(p);                        
+                        XMLUtils.createElement(contenthandler, "fullscreen-uri", link);
+                    }
+
+                    String[] supportedModes = (String[])copletInstanceData.getTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_PORTLET_MODES);
+                    String pm = windowSession.getMode();
+                    if ( pm == null ) {
+                        pm = Modes._view;
+                    }
+                    if ( !pm.equals(Modes._edit) 
+                         && ArrayUtils.contains(supportedModes, Modes._edit) ) {
+                        final Map p = new HashMap();
+                        p.put(Constants.URL_TYPE, Constants.URL_TYPE_RENDER);
+                        p.put(Constants.PORTLET_MODE, Modes._edit);
+
+                        final String link = urlGenerator.getRenderURL(p);                        
+                        XMLUtils.createElement(contenthandler, "edit-uri", link);                    
+                    }
+                    if ( !pm.equals(Modes._help)
+                        && ArrayUtils.contains(supportedModes, Modes._help) ) {
+                        final Map p = new HashMap();
+                        p.put(Constants.URL_TYPE, Constants.URL_TYPE_RENDER);
+                        p.put(Constants.PORTLET_MODE, Modes._help);
+
+                        final String link = urlGenerator.getRenderURL(p);                        
+                        XMLUtils.createElement(contenthandler, "help-uri", link);                    
+                    }                
+                    if ( !pm.equals(Modes._view)
+                        && ArrayUtils.contains(supportedModes, Modes._view) ) {
+                        final Map p = new HashMap();
+                        p.put(Constants.URL_TYPE, Constants.URL_TYPE_RENDER);
+                        p.put(Constants.PORTLET_MODE, Modes._view);
+
+                        final String link = urlGenerator.getRenderURL(p);                        
+                        XMLUtils.createElement(contenthandler, "view-uri", link);                    
+                    } 
+                }
+            } catch (WSRPException ignore) {
+                // we ignore this
+            } finally {
+                this.adapter.setCurrentCopletInstanceData(null);                
+            }
+
+        }
+
+        context.invokeNext( layout, service, contenthandler );
+        
+        if ( config.rootTag ) {
+            XMLUtils.endElement(contenthandler, config.tagName);
+        }
+    }
+
+    /**
+     * utility-class to get the tags out of the configuration<br/>
+     * 
+     * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+     * @author <a href="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
+     * 
+     * @version $Id$
+     */
+    protected static class PreparedConfiguration {
+        
+        /** name of the element */
+        public String tagName;
+        
+        /** shows if the element is on the highest level */
+        public boolean rootTag;
+        
+        /**
+         * set the configuration to the local attributes<br/>
+         * 
+         * @param from the object with the configuration-values
+         */
+        public void takeValues(PreparedConfiguration from) {
+            this.tagName = from.tagName;
+            this.rootTag = from.rootTag;
+        }
+    }
+    
+    /**
+     * @see org.apache.cocoon.portal.layout.renderer.aspect.RendererAspect#prepareConfiguration(org.apache.avalon.framework.parameters.Parameters)
+     */
+    public Object prepareConfiguration(Parameters configuration) 
+    throws ParameterException {
+        PreparedConfiguration pc = new PreparedConfiguration();
+        pc.tagName = configuration.getParameter("tag-name", "window");
+        pc.rootTag = configuration.getParameterAsBoolean("root-tag", true);
+        return pc;
+    }
+
+    /**
+     * provides an link including the wsrp-link and the current event-state<br/>
+     * 
+     * @param linkService
+     * @param urlGenerator
+     * @param cid
+     * @param windowStates
+     * @param size
+     * @return String the link for the portal
+     */
+    protected String createLink(LinkService linkService,
+                                URLGenerator urlGenerator,
+                                CopletInstanceData cid,
+                                WindowStates windowStates,
+                                Integer size) {
+        ChangeCopletInstanceAspectDataEvent event;
+        event = new ChangeCopletInstanceAspectDataEvent(cid, "size", size);
+        
+        return this.createLink(linkService, urlGenerator, cid, windowStates, event);
+    }
+
+    /**
+     * provides an link including the wsrp-link and the current event-state<br/>
+     * 
+     * @param linkService
+     * @param urlGenerator
+     * @param cid
+     * @param windowStates
+     * @param event
+     * @return String the link for the portal
+     */
+    protected String createLink(LinkService linkService,
+                                URLGenerator urlGenerator,
+                                CopletInstanceData cid,
+                                WindowStates windowStates,
+                                Event event) {
+        // create the link for the wsrp window state first
+        final Map p = new HashMap();
+        p.put(Constants.URL_TYPE, Constants.URL_TYPE_RENDER);
+        p.put(Constants.WINDOW_STATE, windowStates.getValue());
+        final String wsrpLink = urlGenerator.getRenderURL(p);
+
+        String link_event = linkService.getLinkURI(event);
+        int pos = link_event.indexOf('?');
+
+        return wsrpLink + link_event.substring(pos+1);
+    }
+}

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/ConsumerEnvironmentImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/ConsumerEnvironmentImpl.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/ConsumerEnvironmentImpl.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/ConsumerEnvironmentImpl.java Tue Aug 30 04:10:28 2005
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.wsrp.consumer;
+
+import oasis.names.tc.wsrp.v1.types.StateChange;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.coplet.CopletInstanceData;
+import org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter;
+import org.apache.wsrp4j.consumer.PortletDriverRegistry;
+import org.apache.wsrp4j.consumer.PortletRegistry;
+import org.apache.wsrp4j.consumer.ProducerRegistry;
+import org.apache.wsrp4j.consumer.SessionHandler;
+import org.apache.wsrp4j.consumer.URLGenerator;
+import org.apache.wsrp4j.consumer.URLRewriter;
+import org.apache.wsrp4j.consumer.URLTemplateComposer;
+import org.apache.wsrp4j.consumer.User;
+import org.apache.wsrp4j.consumer.UserRegistry;
+import org.apache.wsrp4j.consumer.driver.GenericConsumerEnvironment;
+import org.apache.wsrp4j.consumer.util.ConsumerConstants;
+import org.apache.wsrp4j.util.Constants;
+import org.apache.wsrp4j.util.Modes;
+import org.apache.wsrp4j.util.WindowStates;
+
+/**
+ * Implements the consumer environment interface. <br/>
+ * 
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * @author <a href="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
+ *
+ * @version $Id$
+ **/
+public class ConsumerEnvironmentImpl
+    extends GenericConsumerEnvironment {
+
+    /** The generator used to rewrite the urls. */
+    protected URLGenerator urlGenerator;
+
+    /** The wsrp adapter. */
+    protected WSRPAdapter adapter;
+
+    /**
+     * Initialize the consumer
+     * 
+     * @param service
+     * @param adapter
+     * @throws Exception
+     */
+    public void init(PortalService service,
+                     WSRPAdapter adapter)
+    throws Exception {
+        this.adapter = adapter;
+        Parameters params = adapter.getAdapterConfiguration();
+        this.setConsumerAgent("not set");
+
+        // To define the locales per end-user 
+        // the configuration must be set within UserContextProviderImpl
+        // the following lines define the global locales
+        String[] supportedLocales = new String[1];
+        supportedLocales[0] = Constants.LOCALE_EN_US;
+        this.setSupportedLocales(supportedLocales);
+
+        // define the modes the consumer supports
+        String[] supportedModes = new String[3];
+        supportedModes[0] = Modes._view;
+        supportedModes[1] = Modes._help;
+        supportedModes[2] = Modes._edit;
+        this.setSupportedModes(supportedModes);
+
+        // define the window states the consumer supports
+        String[] supportedWindowStates = new String[3];
+        supportedWindowStates[0] = WindowStates._normal;
+        supportedWindowStates[1] = WindowStates._maximized;
+        supportedWindowStates[2] = WindowStates._minimized;
+        this.setSupportedWindowStates(supportedWindowStates);
+
+        // define portlet state change behaviour
+        this.setPortletStateChange(StateChange.readWrite);
+
+        // define the mime types the consumer supports        
+        this.setMimeTypes(new String[] { Constants.MIME_TYPE_HTML });
+
+        // define the character sets the consumer supports        
+        this.setCharacterEncodingSet(new String[] { Constants.UTF_8 });
+
+        // set the authentication method the consumer uses
+        this.setUserAuthentication(ConsumerConstants.NONE);
+
+        // THE ORDER IN WHICH THE FOLLOWING OBJECTS ARE INSTANCIATED IS IMPORTANT
+        this.setUserRegistry((UserRegistry)adapter.createObject(params.getParameter("user-registry-class", UserRegistryImpl.class.getName())));
+        this.setSessionHandler((SessionHandler)adapter.createObject(params.getParameter("session-handler-class", SessionHandlerImpl.class.getName())));
+        this.setProducerRegistry((ProducerRegistry)adapter.createObject(params.getParameter("producer-registry-class", ProducerRegistryImpl.class.getName())));
+        this.setPortletRegistry((PortletRegistry)adapter.createObject(params.getParameter("portlet-registry-class", PortletRegistryImpl.class.getName())));
+
+        this.setTemplateComposer((URLTemplateComposer)adapter.createObject(params.getParameter("url-template-composer-class", URLTemplateComposerImpl.class.getName())));
+        this.setURLRewriter((URLRewriter)adapter.createObject(params.getParameter("url-rewriter-class", URLRewriterImpl.class.getName())));
+
+        this.setPortletDriverRegistry((PortletDriverRegistry)adapter.createObject(params.getParameter("portlet-driver-registry-class", PortletDriverRegistryImpl.class.getName())));
+
+        this.urlGenerator = (URLGenerator)adapter.createObject(params.getParameter("url-generator-class", URLGeneratorImpl.class.getName()));
+        this.getTemplateComposer().setURLGenerator(this.urlGenerator);
+        this.getURLRewriter().setURLGenerator(this.urlGenerator);
+    }
+
+    /**
+     * @return URLGenerator the used url generator.
+     */
+    public URLGenerator getURLGenerator() {
+        return this.urlGenerator;
+    }
+    
+    /**
+     * @see org.apache.wsrp4j.consumer.driver.GenericConsumerEnvironment#getSupportedLocales()
+     */
+    public String[] getSupportedLocales() {
+        CopletInstanceData coplet = this.adapter.getCurrentCopletInstanceData();
+        User user = (User)coplet.getTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_USER);
+        
+        return ((UserContextExtension)user.getUserContext()).getSupportedLocales();
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.ConsumerCapabilities#getUserAuthentication()
+     */
+    public String getUserAuthentication() {
+        CopletInstanceData coplet = this.adapter.getCurrentCopletInstanceData();
+        User user = (User)coplet.getTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_USER);
+        
+        return ((UserContextExtension)user.getUserContext()).getUserAuthentication();
+    }    
+}

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/ConsumerEnvironmentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/ConsumerEnvironmentImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/GroupSessionImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/GroupSessionImpl.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/GroupSessionImpl.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/GroupSessionImpl.java Tue Aug 30 04:10:28 2005
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.wsrp.consumer;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.wsrp4j.consumer.PortletSession;
+import org.apache.wsrp4j.consumer.driver.GenericGroupSessionImpl;
+import org.apache.wsrp4j.exception.WSRPException;
+
+/**
+ * Implements a consumer based group session<br/>
+ *
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * @author <a href="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
+ * 
+ * @version $Id$
+ */
+public class GroupSessionImpl extends GenericGroupSessionImpl {
+
+    /** The logger. */
+    protected Logger logger;
+
+	/**
+	 * Constructs a new <code>GroupSessionImpl</code> object with the given groupID.
+	 * The portletServicesURL is needed for implementing the <code>PortletServices</code>
+	 * interface.
+	 * 
+	 * @see org.apache.wsrp4j.consumer.PortletServices
+     * 	  	
+     * @param groupID
+     * @param markupInterfaceURL
+     * @param logger
+     * @throws WSRPException
+     */
+    public GroupSessionImpl(String groupID, String markupInterfaceURL, Logger logger)
+    throws WSRPException {
+        super(groupID, markupInterfaceURL);
+        this.logger = logger;
+    }
+
+	/**
+	* Get the portlet session object which is identified with
+	* the given instanceKey from the group session. If no portlet session
+	* with that instanceKey exists it depends of the implementation wether
+	* null or a newly created portlet session object is returned.
+	* 
+	* @param handle The key which identifies the portlet session object
+	* 
+	* @return PortletSession The portlet session with the given key
+	**/
+    public PortletSession getPortletSession(String handle) {
+        if (handle == null) {
+            return null;
+        }
+
+        PortletSession portletSession = (PortletSession)portletSessions.get(handle);
+        if (portletSession == null) {
+            portletSession = new PortletSessionImpl(handle, this.logger);
+            addPortletSession(portletSession);
+        }
+
+        return portletSession;
+    }
+}
\ No newline at end of file