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 12:30:18 UTC

svn commit: r264755 [2/4] - in /cocoon/branches/BRANCH_2_1_X: ./ legal/ lib/ lib/optional/ src/blocks/portal/conf/ src/blocks/portal/java/org/apache/cocoon/portal/wsrp/ src/blocks/portal/java/org/apache/cocoon/portal/wsrp/adapter/ src/blocks/portal/jav...

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEventAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEventAspect.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEventAspect.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEventAspect.java Tue Aug 30 03:29:21 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/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/adapter/WSRPEventAspect.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java Tue Aug 30 03:29:21 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/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/adapter/WSRPPortletWindowAspect.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ConsumerEnvironmentImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ConsumerEnvironmentImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ConsumerEnvironmentImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ConsumerEnvironmentImpl.java Tue Aug 30 03:29:21 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/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ConsumerEnvironmentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/GroupSessionImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/GroupSessionImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/GroupSessionImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/GroupSessionImpl.java Tue Aug 30 03:29:21 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

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/GroupSessionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/GroupSessionImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverImpl.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,772 @@
+/*
+ * 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.intf.WSRP_v1_Markup_PortType;
+import oasis.names.tc.wsrp.v1.intf.WSRP_v1_PortletManagement_PortType;
+import oasis.names.tc.wsrp.v1.types.BlockingInteractionResponse;
+import oasis.names.tc.wsrp.v1.types.ClientData;
+import oasis.names.tc.wsrp.v1.types.CookieProtocol;
+import oasis.names.tc.wsrp.v1.types.DestroyPortletsResponse;
+import oasis.names.tc.wsrp.v1.types.Extension;
+import oasis.names.tc.wsrp.v1.types.InteractionParams;
+import oasis.names.tc.wsrp.v1.types.InvalidCookieFault;
+import oasis.names.tc.wsrp.v1.types.MarkupContext;
+import oasis.names.tc.wsrp.v1.types.MarkupParams;
+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.PortletDescriptionResponse;
+import oasis.names.tc.wsrp.v1.types.PortletPropertyDescriptionResponse;
+import oasis.names.tc.wsrp.v1.types.PropertyList;
+import oasis.names.tc.wsrp.v1.types.RegistrationContext;
+import oasis.names.tc.wsrp.v1.types.ReturnAny;
+import oasis.names.tc.wsrp.v1.types.RuntimeContext;
+import oasis.names.tc.wsrp.v1.types.ServiceDescription;
+import oasis.names.tc.wsrp.v1.types.StateChange;
+import oasis.names.tc.wsrp.v1.types.Templates;
+import oasis.names.tc.wsrp.v1.types.UserContext;
+import oasis.names.tc.wsrp.v1.types.ClonePortlet;
+import oasis.names.tc.wsrp.v1.types.DestroyPortlets;
+import oasis.names.tc.wsrp.v1.types.GetMarkup;
+import oasis.names.tc.wsrp.v1.types.GetPortletDescription;
+import oasis.names.tc.wsrp.v1.types.GetPortletProperties;
+import oasis.names.tc.wsrp.v1.types.GetPortletPropertyDescription;
+import oasis.names.tc.wsrp.v1.types.InitCookie;
+import oasis.names.tc.wsrp.v1.types.PerformBlockingInteraction;
+import oasis.names.tc.wsrp.v1.types.ReleaseSessions;
+import oasis.names.tc.wsrp.v1.types.SetPortletProperties;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.wsrp.logging.WSRPLogger;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.wsrp4j.consumer.ConsumerEnvironment;
+import org.apache.wsrp4j.consumer.GroupSessionMgr;
+import org.apache.wsrp4j.consumer.InteractionRequest;
+import org.apache.wsrp4j.consumer.MarkupRequest;
+import org.apache.wsrp4j.consumer.PortletDriver;
+import org.apache.wsrp4j.consumer.Producer;
+import org.apache.wsrp4j.consumer.URLRewriter;
+import org.apache.wsrp4j.consumer.URLTemplateComposer;
+import org.apache.wsrp4j.consumer.User;
+import org.apache.wsrp4j.consumer.UserSessionMgr;
+import org.apache.wsrp4j.consumer.WSRPBaseRequest;
+import org.apache.wsrp4j.consumer.WSRPPortlet;
+import org.apache.wsrp4j.exception.WSRPException;
+import org.apache.wsrp4j.exception.WSRPXHelper;
+import org.apache.wsrp4j.log.Logger;
+import org.apache.wsrp4j.util.Constants;
+import org.apache.wsrp4j.util.ParameterChecker;
+
+/**
+ * This class implements a portlet driver.
+ * @version $Id$
+ **/
+public class PortletDriverImpl
+    extends AbstractLogEnabled
+    implements PortletDriver, RequiresConsumerEnvironment, RequiresPortalService {
+
+    protected WSRPPortlet portlet;
+    protected WSRP_v1_Markup_PortType markupPort;
+    protected WSRP_v1_PortletManagement_PortType portletPort;
+    protected ConsumerEnvironment consumerEnv;
+    protected Producer producer;
+    protected ParameterChecker parameterChecker;
+    protected CookieProtocol initCookie = CookieProtocol.none;
+    protected PortletDescription desc;
+
+    /** Our logger. */
+    protected Logger logger;
+
+    /** The portal service. */
+    protected PortalService service;
+
+    /**
+     * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
+     */
+    public void enableLogging(org.apache.avalon.framework.logger.Logger arg0) {
+        super.enableLogging(arg0);
+        this.logger = new WSRPLogger(arg0);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.wsrp.consumer.RequiresConsumerEnvironment#setConsumerEnvironment(org.apache.wsrp4j.consumer.ConsumerEnvironment)
+     */
+    public void setConsumerEnvironment(ConsumerEnvironment env) {
+        this.consumerEnv = env;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.wsrp.consumer.RequiresPortalService#setPortalService(org.apache.cocoon.portal.PortalService)
+     */
+    public void setPortalService(PortalService service) {
+       this.service = service;
+    }
+
+    /**
+     * Set the wsrp portlet and initialize this component.
+     * @param portlet
+     * @throws WSRPException
+     */
+    public void init(WSRPPortlet portlet) 
+    throws WSRPException {
+		this.parameterChecker = new ParameterChecker();
+
+        this.portlet = portlet;
+        this.producer = consumerEnv.getProducerRegistry().getProducer(portlet.getPortletKey().getProducerId());
+        
+        this.portletPort = this.producer.getPortletManagementInterface();
+        this.desc = this.producer.getPortletDescription(this.portlet.getPortletKey().getPortletHandle());
+
+        ServiceDescription serviceDescription = this.producer.getServiceDescription(false);
+        if (serviceDescription != null) {
+            this.initCookie = serviceDescription.getRequiresInitCookie();
+            if (initCookie == null) {
+                initCookie = CookieProtocol.none; // TODO - get from config
+            }
+        }
+    }
+
+    /**
+     * Get the portlet this driver is bind to.
+     * 
+     * @return The enity
+     **/
+    public WSRPPortlet getPortlet() {
+        return this.portlet;
+    }
+
+    protected void resetInitCookie(String userID) throws WSRPException {
+
+        UserSessionMgr userSession =
+            this.consumerEnv.getSessionHandler().getUserSession(
+                getPortlet().getPortletKey().getProducerId(),
+                userID);
+
+        if (initCookie.getValue().equalsIgnoreCase(CookieProtocol._none)) {
+
+            userSession.setInitCookieDone(false);
+
+        } else if (initCookie.getValue().equalsIgnoreCase(CookieProtocol._perGroup)) {
+
+            PortletDescription portletDescription = null;
+            try {
+
+                portletDescription = producer.getPortletDescription(getPortlet().getParent());
+
+            } catch (WSRPException e) {
+
+                // do nothing since exception has been logged already
+
+            }
+
+            String groupID = null;
+            if (portletDescription != null) {
+                groupID = portletDescription.getGroupID();
+            }
+
+            if (groupID != null) {
+                GroupSessionMgr groupSession = userSession.getGroupSession(groupID);
+                groupSession.setInitCookieDone(false);
+            }
+        }
+    }
+
+    protected void checkInitCookie(String userID) throws WSRPException {
+        UserSessionMgr userSession =
+            this.consumerEnv.getSessionHandler().getUserSession(
+                getPortlet().getPortletKey().getProducerId(),
+                userID);
+
+        if (initCookie.getValue().equalsIgnoreCase(CookieProtocol._perUser)) {
+
+            this.markupPort = userSession.getWSRPBaseService();
+
+            if (!userSession.isInitCookieDone()) {
+
+                userSession.setInitCookieRequired(true);
+                initCookie();
+                userSession.setInitCookieDone(true);
+            }
+
+        } else if (initCookie.getValue().equalsIgnoreCase(CookieProtocol._perGroup)) {
+
+            PortletDescription portletDescription = producer.getPortletDescription(getPortlet().getParent());
+            String groupID = null;
+            if (portletDescription != null) {
+                groupID = portletDescription.getGroupID();
+            }
+
+            if (groupID != null) {
+                GroupSessionMgr groupSession = userSession.getGroupSession(groupID);
+
+                this.markupPort = groupSession.getWSRPBaseService();
+
+                if (!groupSession.isInitCookieDone()) {
+                    groupSession.setInitCookieRequired(true);
+                    initCookie();
+                    groupSession.setInitCookieDone(true);
+                }
+
+            } else {
+                // means either we have no service description from the producer containg the portlet
+                // or the producer specified initCookieRequired perGroup but didn't provide
+                // a groupID in the portlet description                             
+            }
+        } else {
+            this.markupPort = userSession.getWSRPBaseService();
+        }
+        
+    }
+
+    protected MarkupParams getMarkupParams(WSRPBaseRequest request) {
+
+        MarkupParams markupParams = new MarkupParams();
+        ClientData clientData = null;
+
+        // lets just set this to the consumer agent for now
+        if (producer.getRegistrationData() != null) {
+            clientData = new ClientData();
+            clientData.setUserAgent(producer.getRegistrationData().getConsumerAgent());
+        }
+        markupParams.setClientData(clientData);
+        markupParams.setSecureClientCommunication(this.service.getComponentManager().getLinkService().isSecure());
+        markupParams.setLocales(consumerEnv.getSupportedLocales());
+
+        markupParams.setMimeTypes(consumerEnv.getMimeTypes());
+
+        markupParams.setMode(request.getMode());
+        markupParams.setWindowState(request.getWindowState());
+        markupParams.setNavigationalState(request.getNavigationalState());
+        markupParams.setMarkupCharacterSets(consumerEnv.getCharacterEncodingSet());
+        markupParams.setValidateTag(null); // TODO ValidateTag
+
+        // TODO we could cache the modes and window states
+        final MarkupType markupType = this.desc.getMarkupTypes(0);
+        markupParams.setValidNewModes(this.getValidValues(consumerEnv.getSupportedModes(), markupType.getModes()));
+        markupParams.setValidNewWindowStates(this.getValidValues(consumerEnv.getSupportedWindowStates(), markupType.getWindowStates()));
+
+        markupParams.setExtensions(this.getMarkupParamsExtensions());
+
+        return markupParams;
+    }
+
+    /**
+     * Calculate the valid values for modes and window states.
+     * @param supported The values supported by the consumer.
+     * @param allowed The values allowed by the producer.
+     * @return The valid values.
+     */
+    protected String[] getValidValues(String[] supported, String[] allowed) {
+        String[] validModes = new String[0];
+        for(int i=0; i < supported.length; i++ ) {
+            if ( ArrayUtils.contains(allowed, supported[i]) ) {
+                String[] newValidModes = new String[validModes.length+1];
+                System.arraycopy(validModes, 0, newValidModes, 0, validModes.length);
+                newValidModes[validModes.length] = supported[i];
+                validModes = newValidModes;
+            }
+        }
+        return validModes;
+    }
+
+    /**
+     * Create the runtime context for the current request.
+     */
+    protected RuntimeContext getRuntimeContext(WSRPBaseRequest request) {
+        RuntimeContext runtimeContext = new RuntimeContext();
+        runtimeContext.setUserAuthentication(consumerEnv.getUserAuthentication());
+        runtimeContext.setPortletInstanceKey(request.getPortletInstanceKey());
+
+        URLTemplateComposer templateComposer = consumerEnv.getTemplateComposer();
+        if (templateComposer != null) {
+            runtimeContext.setNamespacePrefix(templateComposer.getNamespacePrefix());
+        }
+
+        Boolean doesUrlTemplateProcess = null;
+        try {
+
+            PortletDescription desc = producer.getPortletDescription(getPortlet().getParent());
+
+            if (desc != null) {
+
+                doesUrlTemplateProcess = desc.getDoesUrlTemplateProcessing();
+            }
+
+        } catch (WSRPException e) {
+
+            // do nothing since exception has been logged already
+            // continue with assumption that portlet does not support template processing
+        }
+
+        if (doesUrlTemplateProcess != null && templateComposer != null && doesUrlTemplateProcess.booleanValue()) {
+            Templates templates = new Templates();
+            templates.setBlockingActionTemplate(templateComposer.createBlockingActionTemplate(true, true, true, true));
+            templates.setRenderTemplate(templateComposer.createRenderTemplate(true, true, true, true));
+            templates.setDefaultTemplate(templateComposer.createDefaultTemplate(true, true, true, true));
+            templates.setResourceTemplate(templateComposer.createResourceTemplate(true, true, true, true));
+            templates.setSecureBlockingActionTemplate(
+                templateComposer.createSecureBlockingActionTemplate(true, true, true, true));
+            templates.setSecureRenderTemplate(templateComposer.createSecureRenderTemplate(true, true, true, true));
+            templates.setSecureDefaultTemplate(templateComposer.createSecureDefaultTemplate(true, true, true, true));
+            templates.setSecureResourceTemplate(templateComposer.createSecureResourceTemplate(true, true, true, true));
+            runtimeContext.setTemplates(templates);
+        }
+
+        runtimeContext.setSessionID(request.getSessionID());
+        runtimeContext.setExtensions(null);
+
+        return runtimeContext;
+    }
+
+    protected UserContext getUserContext(String userID) {
+        UserContext userContext = null;
+
+        if (userID != null) {
+            User user = consumerEnv.getUserRegistry().getUser(userID);
+
+            if (user != null) {
+                userContext = user.getUserContext();
+            }
+        }
+        
+        // workaround for Oracle bug, always send a userContext with dummy value
+        // if none was provided
+        
+        if (userContext == null) {
+        	userContext = new UserContext();
+        	userContext.setUserContextKey("dummyUserContextKey");
+        }
+
+        return userContext;
+    }
+
+    protected InteractionParams getInteractionParams(InteractionRequest actionRequest) {
+        InteractionParams interactionParams = new InteractionParams();
+
+        interactionParams.setPortletStateChange(consumerEnv.getPortletStateChange());
+        
+        // access POPs with cloneBeforeWrite
+        // however keep the default behaviour from ConsEnv
+        // this means that if readWrite is set and we access a POP then set to cloneBeforeWrite
+        if (!portlet.isConsumerConfigured() &&
+             interactionParams.getPortletStateChange().toString().equalsIgnoreCase(StateChange._readWrite)) {
+             	interactionParams.setPortletStateChange(StateChange.cloneBeforeWrite);
+       	}
+        
+        interactionParams.setInteractionState(actionRequest.getInteractionState());
+        interactionParams.setFormParameters(actionRequest.getFormParameters());
+        interactionParams.setUploadContexts(null);
+        interactionParams.setExtensions(null);
+
+        return interactionParams;
+    }
+
+    /**
+      * This method is used to retrieve the markup generated by the portlet instance.
+      * 
+      * @param markupRequest 
+      * @param userID
+      * @return The markup response generated by the portlet
+      **/
+    public MarkupResponse getMarkup(MarkupRequest markupRequest,
+                                    String userID)
+    throws WSRPException {
+        checkInitCookie(userID);
+
+        MarkupResponse response = null;
+
+        try {
+
+            MarkupContext markupContext = null;
+            if ((markupContext = markupRequest.getCachedMarkup()) == null) {
+
+                // getMarkup request
+                GetMarkup request = new GetMarkup();
+
+                request.setPortletContext(getPortlet().getPortletContext());
+                request.setMarkupParams(getMarkupParams(markupRequest));
+                request.setRuntimeContext(getRuntimeContext(markupRequest));
+
+                RegistrationContext regCtx = producer.getRegistrationContext();
+                if (regCtx != null)
+                    request.setRegistrationContext(regCtx);
+
+                UserContext userCtx = getUserContext(userID);
+                if (userCtx != null) {
+                    request.setUserContext(getUserContext(userID));
+                }
+
+                response = markupPort.getMarkup(request);
+
+                parameterChecker.check(response);
+
+            } else {
+
+                response = new MarkupResponse();
+                response.setMarkupContext(markupContext);
+            }            
+            
+            Boolean requiresRewriting = response.getMarkupContext().getRequiresUrlRewriting();
+            requiresRewriting = requiresRewriting == null ? Boolean.FALSE : requiresRewriting;
+
+            if (requiresRewriting.booleanValue()) {
+                // rewrite url's
+
+                URLRewriter urlRewriter = consumerEnv.getURLRewriter();
+                String rewrittenMarkup = urlRewriter.rewriteURLs(response.getMarkupContext().getMarkupString());
+
+                if (rewrittenMarkup != null) {
+                    response.getMarkupContext().setMarkupString(rewrittenMarkup);
+                }
+            }
+
+        } catch (InvalidCookieFault cookieFault) {
+
+            // lets reset the init cookie settings
+            resetInitCookie(userID);
+
+            // and try it again
+            response = getMarkup(markupRequest, userID);
+
+        } catch (java.rmi.RemoteException wsrpFault) {
+
+            WSRPXHelper.handleWSRPFault(logger, wsrpFault);
+
+        }
+
+        return response;
+    }
+
+    /**
+     * This method is used to perform a blocking interaction on the portlet instance.
+     * 
+     * @param actionRequest 
+     **/
+    public BlockingInteractionResponse performBlockingInteraction(InteractionRequest actionRequest,
+                                                                  String userID)
+    throws WSRPException {
+
+        checkInitCookie(userID);
+
+        BlockingInteractionResponse response = null;
+
+        try {
+            PerformBlockingInteraction request = new PerformBlockingInteraction();
+
+            request.setPortletContext(getPortlet().getPortletContext());
+            request.setInteractionParams(getInteractionParams(actionRequest));
+            request.setMarkupParams(getMarkupParams(actionRequest));
+            request.setRuntimeContext(getRuntimeContext(actionRequest));
+
+            RegistrationContext regCtx = producer.getRegistrationContext();
+            if (regCtx != null)
+                request.setRegistrationContext(regCtx);
+
+            UserContext userCtx = getUserContext(userID);
+            if (userCtx != null)
+                request.setUserContext(userCtx);
+
+            response = markupPort.performBlockingInteraction(request);
+
+            parameterChecker.check(response);
+
+        } catch (InvalidCookieFault cookieFault) {
+
+            // lets reset the init cookie settings
+            resetInitCookie(userID);
+
+            // and try it again
+            response = performBlockingInteraction(actionRequest, userID);
+
+        } catch (java.rmi.RemoteException wsrpFault) {
+
+            WSRPXHelper.handleWSRPFault(logger, wsrpFault);
+        }
+
+        return response;
+    }
+
+    /**
+     * Clone the portlet
+     * 
+     * @return The new portlet context
+     **/
+    public PortletContext clonePortlet(String userID) throws WSRPException {
+        ClonePortlet request = new ClonePortlet();
+
+        request.setPortletContext(getPortlet().getPortletContext());
+
+        RegistrationContext regCtx = producer.getRegistrationContext();
+        if (regCtx != null)
+            request.setRegistrationContext(regCtx);
+
+        UserContext userCtx = getUserContext(userID);
+        if (userCtx != null)
+            request.setUserContext(userCtx);
+
+        PortletContext response = null;
+
+        try {
+
+            response = portletPort.clonePortlet(request);
+            parameterChecker.check(response, Constants.NILLABLE_FALSE);
+
+        } catch (java.rmi.RemoteException wsrpFault) {
+
+            WSRPXHelper.handleWSRPFault(logger, wsrpFault);
+        }
+
+        return response;
+    }
+
+    /**
+     * Destroy the producer portlets specified in the entiyHandles array.    
+     **/
+    public DestroyPortletsResponse destroyPortlets(String[] portletHandles,
+                                                   String userID)
+    throws WSRPException {
+        DestroyPortlets request = new DestroyPortlets();
+
+        RegistrationContext regCtx = producer.getRegistrationContext();
+        if (regCtx != null)
+            request.setRegistrationContext(regCtx);
+
+        request.setPortletHandles(portletHandles);
+
+        DestroyPortletsResponse response = null;
+        try {
+
+            response = portletPort.destroyPortlets(request);
+            parameterChecker.check(response);
+
+        } catch (java.rmi.RemoteException wsrpFault) {
+
+            WSRPXHelper.handleWSRPFault(logger, wsrpFault);
+        }
+
+        return response;
+    }
+
+    /**
+     * Inform the producer that the sessions specified in the sessionIDs array
+     * will no longer be used by the consumer and can therefor be released.     
+     **/
+    public ReturnAny releaseSessions(String[] sessionIDs,
+                                     String userID)
+    throws WSRPException {
+
+        checkInitCookie(userID);
+
+        ReleaseSessions request = new ReleaseSessions();
+
+        RegistrationContext regCtx = producer.getRegistrationContext();
+        if (regCtx != null)
+            request.setRegistrationContext(regCtx);
+
+        request.setSessionIDs(sessionIDs);
+
+        ReturnAny response = null;
+        try {
+
+            response = markupPort.releaseSessions(request);
+
+        } catch (java.rmi.RemoteException wsrpFault) {
+
+            WSRPXHelper.handleWSRPFault(logger, wsrpFault);
+        }
+
+        return response;
+    }
+
+    /**
+     * Actual WSRP initCookie() call
+     **/
+    public void initCookie() throws WSRPException {
+        InitCookie request = new InitCookie();
+
+        RegistrationContext regCtx = producer.getRegistrationContext();
+        if (regCtx != null)
+            request.setRegistrationContext(regCtx);
+
+        try {
+
+            markupPort.initCookie(request);
+
+        } catch (java.rmi.RemoteException wsrpFault) {
+            WSRPXHelper.handleWSRPFault(logger, wsrpFault);
+        }
+    }
+
+    /**
+     * Fetches information about the portlet from the producer. 
+     * 
+     * @param userID is used to get the user context of the user from the user registry
+     * @param desiredLocales Array of locales the description should be provided
+     * 
+     * @return The response to the getPortletDescription call.
+     **/
+    public PortletDescriptionResponse getPortletDescription(String userID,
+                                                            String[] desiredLocales)
+    throws WSRPException {
+        GetPortletDescription request = new GetPortletDescription();
+
+        RegistrationContext regCtx = producer.getRegistrationContext();
+        if (regCtx != null)
+            request.setRegistrationContext(regCtx);
+
+        request.setPortletContext(getPortlet().getPortletContext());
+
+        UserContext userCtx = getUserContext(userID);
+        if (userCtx != null)
+            request.setUserContext(userCtx);
+
+        request.setDesiredLocales(desiredLocales);
+
+        PortletDescriptionResponse response = null;
+
+        try {
+
+            response = portletPort.getPortletDescription(request);
+            parameterChecker.check(response);
+
+        } catch (java.rmi.RemoteException wsrpFault) {
+
+            WSRPXHelper.handleWSRPFault(logger, wsrpFault);
+        }
+
+        return response;
+    }
+
+    /**
+     * Fetches all published properties of an remote portlet.
+     * 
+     * @param userID The ID of the user this request is done for
+     * 
+     * @return The portlet property description response from the producer
+     **/
+    public PortletPropertyDescriptionResponse getPortletPropertyDescription(String userID)
+    throws WSRPException {
+        GetPortletPropertyDescription request = new GetPortletPropertyDescription();
+        request.setPortletContext(getPortlet().getPortletContext());
+
+        RegistrationContext regCtx = producer.getRegistrationContext();
+        if (regCtx != null)
+            request.setRegistrationContext(regCtx);
+
+        UserContext userCtx = getUserContext(userID);
+        if (userCtx != null)
+            request.setUserContext(userCtx);
+
+        request.setDesiredLocales(consumerEnv.getSupportedLocales());
+
+        PortletPropertyDescriptionResponse response = null;
+
+        try {
+
+            response = portletPort.getPortletPropertyDescription(request);
+            parameterChecker.check(response);
+
+        } catch (java.rmi.RemoteException wsrpFault) {
+
+            WSRPXHelper.handleWSRPFault(logger, wsrpFault);
+        }
+
+        return response;
+    }
+
+    /**
+     * Get the current values of the properties with the given names.
+     * 
+     * @param names The names of the properties
+     * @param userID The ID of the user is used to get the user context
+     * 
+     * @return A list of properties containing the values and names of the properties.
+     **/
+    public PropertyList getPortletProperties(String[] names, String userID)
+    throws WSRPException {
+        GetPortletProperties request = new GetPortletProperties();
+        request.setPortletContext(getPortlet().getPortletContext());
+        request.setNames(names);
+
+        RegistrationContext regCtx = producer.getRegistrationContext();
+        if (regCtx != null)
+            request.setRegistrationContext(regCtx);
+
+        UserContext userCtx = getUserContext(userID);
+        if (userCtx != null)
+            request.setUserContext(userCtx);
+
+        PropertyList response = null;
+
+        try {
+
+            response = portletPort.getPortletProperties(request);
+            parameterChecker.check(response, Constants.NILLABLE_FALSE);
+
+        } catch (java.rmi.RemoteException wsrpFault) {
+
+            WSRPXHelper.handleWSRPFault(logger, wsrpFault);
+        }
+
+        return response;
+    }
+
+    /**
+     * Set the portlet properties specified in the property list
+     * 
+     * @param properties List of properties to be set.
+     * @param userID The ID of the user is used to get the user context
+     **/
+    public PortletContext setPortletProperties(PropertyList properties, String userID)
+    throws WSRPException {
+        SetPortletProperties request = new SetPortletProperties();
+        request.setPortletContext(getPortlet().getPortletContext());
+
+        RegistrationContext regCtx = producer.getRegistrationContext();
+        if (regCtx != null)
+            request.setRegistrationContext(regCtx);
+
+        UserContext userCtx = getUserContext(userID);
+        if (userCtx != null)
+            request.setUserContext(userCtx);
+        request.setPropertyList(properties);
+
+        PortletContext response = null;
+
+        try {
+
+            response = portletPort.setPortletProperties(request);
+            parameterChecker.check(response, Constants.NILLABLE_FALSE);
+
+        } catch (java.rmi.RemoteException wsrpFault) {
+
+            WSRPXHelper.handleWSRPFault(logger, wsrpFault);
+        }
+
+        return response;
+    }
+
+    /**
+     * Get the extensions for the MarkupContext.
+     */
+    protected Extension[] getMarkupParamsExtensions() {
+        // this can be overwritten in sub classes
+        return null;
+    }
+}

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverRegistryImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverRegistryImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverRegistryImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverRegistryImpl.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,98 @@
+/*
+ * 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 java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter;
+import org.apache.wsrp4j.consumer.ConsumerEnvironment;
+import org.apache.wsrp4j.consumer.PortletDriver;
+import org.apache.wsrp4j.consumer.PortletDriverRegistry;
+import org.apache.wsrp4j.consumer.WSRPPortlet;
+import org.apache.wsrp4j.exception.WSRPException;
+
+/**
+ * Manages the drivers for the portlets the consumerEnvironment holds<br/>
+ * Per portlet one portletDriver will be stored<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 PortletDriverRegistryImpl
+    implements PortletDriverRegistry,
+               RequiresConsumerEnvironment,
+               RequiresWSRPAdapter {
+
+    /** All portletDrivers the consumerEnvironment needs. */
+    protected final Hashtable portletDrivers = new Hashtable();
+    
+    /** The consumer environment. */
+    protected ConsumerEnvironment consumerEnv;
+
+    /** The WSRP adapter. */
+    protected WSRPAdapter adapter;
+
+    /**
+     * @see org.apache.cocoon.portal.wsrp.consumer.RequiresConsumerEnvironment#setConsumerEnvironment(org.apache.wsrp4j.consumer.ConsumerEnvironment)
+     */
+    public void setConsumerEnvironment(ConsumerEnvironment env) {
+        this.consumerEnv = env;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.wsrp.consumer.RequiresWSRPAdapter#setWSRPAdapter(org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter)
+     */
+    public void setWSRPAdapter(WSRPAdapter adapter) {
+        this.adapter = adapter;
+    }
+
+    /**
+     * Get an portlet driver for the given portlet. If there is no portlet driver
+     * object cached a new portlet driver will be created and returned.
+     * 
+     * @param portlet The portlet the returned portlet driver is bound to.
+     * 
+     * @return The portlet driver for this portlet.
+     **/
+    public PortletDriver getPortletDriver(WSRPPortlet portlet)
+    throws WSRPException {
+        PortletDriver driver = null;
+
+        if ((driver = (PortletDriver)portletDrivers.get(portlet.getPortletKey().toString())) == null) {
+            String driverClass = this.adapter.getAdapterConfiguration().getParameter("portlet-driver-class", PortletDriverImpl.class.getName());
+            try {
+                driver = (PortletDriverImpl)this.adapter.createObject(driverClass);
+            } catch (Exception e) {
+                throw new WSRPException(0, e);
+            }
+            ((PortletDriverImpl)driver).init(portlet);
+            this.portletDrivers.put(portlet.getPortletKey().toString(), driver);
+        }
+        return driver;
+    }
+
+    /**
+     * Get all cached portlet drivers.
+     * 
+     * @return Iterator with all portlet drivers in the registry.
+     **/
+    public Iterator getAllPortletDrivers() {
+        return portletDrivers.values().iterator();
+    }
+}

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverRegistryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverRegistryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletRegistryImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletRegistryImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletRegistryImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletRegistryImpl.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,134 @@
+/*
+ * 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 java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.wsrp4j.consumer.PortletKey;
+import org.apache.wsrp4j.consumer.WSRPPortlet;
+import org.apache.wsrp4j.consumer.driver.ConsumerPortletContext;
+import org.apache.wsrp4j.consumer.driver.GenericPortletRegistryImpl;
+import org.apache.wsrp4j.exception.WSRPException;
+import org.apache.wsrp4j.util.StateChangedEvent;
+import org.apache.wsrp4j.util.StateChangedListener;
+import org.apache.wsrp4j.util.StateChangedService;
+
+/**
+ * This class is the <code>PortletRegistry</code> implementation used
+ * to administer, store, load and manage portlets.<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 PortletRegistryImpl
+    extends GenericPortletRegistryImpl
+    implements StateChangedListener, LogEnabled {
+
+    /** The logger. */
+    protected Logger logger;
+
+    /** maps portlet keys to portlet context. */
+    private Hashtable contextMap = new Hashtable();
+
+    /**
+     * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
+     */
+    public void enableLogging(Logger logger) {
+        this.logger = logger;
+    }
+
+    /**
+     * Add a portlet to the registry<br/>
+     *
+     * @param portlet The portlet to add
+     * @throws WSRPException on error
+     */
+    public void addPortlet(WSRPPortlet portlet) throws WSRPException {
+        if (portlet != null) {
+            super.addPortlet(portlet);
+
+            // store PortletContext to persistent file
+            ConsumerPortletContext consumerPortletContext = new ConsumerPortletContext();
+            consumerPortletContext.setPortletContext(portlet.getPortletContext());
+            consumerPortletContext.setPortletKey(portlet.getPortletKey());
+            this.contextMap.put(portlet.getPortletKey().toString(), consumerPortletContext);
+
+            // add as listener
+            if (portlet instanceof StateChangedService) {
+                ((StateChangedService)portlet).addListener(this);
+            }
+        }
+    }
+
+    /**
+     * Remove the portlet with the given portlet key<br/>
+     *
+     * @param portletKey The portlet key identifying the portlet
+     * @return returns the removed instance of WSRPPortlet
+     **/
+    public WSRPPortlet removePortlet(PortletKey portletKey) {
+        WSRPPortlet portlet = null;
+        if (portletKey != null) {
+            portlet = super.removePortlet(portletKey);
+            contextMap.remove(portletKey.toString());
+        }
+        return portlet;
+    }
+
+    /**
+     * Remove all portlets from the registry and delete them in the
+     * persistent store.
+     **/
+    public void removeAllPortlets() {
+        Iterator iterator = getAllPortlets();
+        while (iterator.hasNext()) {
+            WSRPPortlet portlet = (WSRPPortlet)iterator.next();
+
+            // remove ConsumerPortletContext from map
+            contextMap.remove(portlet.getPortletKey().toString());
+        }
+        super.removeAllPortlets();
+    }
+
+    /**
+     * StateChanged Event occured by a registered WSRPPortlet. The
+     * input source object, contained in the event will be
+     * updated in the persistence store.
+     * 
+     * @param event 
+     * @see StateChangedEvent
+     */
+    public void stateChanged(StateChangedEvent event) {
+        WSRPPortlet portlet = null;
+        try {
+            portlet = (WSRPPortlet)event.getSource();
+
+            //store PortletContext to persistent file
+            ConsumerPortletContext consumerPortletContext =
+                (ConsumerPortletContext)contextMap.get(portlet.getPortletKey().toString());
+
+            consumerPortletContext.setPortletContext(portlet.getPortletContext());
+            consumerPortletContext.setPortletKey(portlet.getPortletKey());
+        } catch (ClassCastException ce) {
+            logger.error("StateChanged-error in portlet: " + portlet.getPortletKey().getPortletHandle(), ce);
+        }
+    }
+}

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletRegistryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletRegistryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletSessionImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletSessionImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletSessionImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletSessionImpl.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,70 @@
+/*
+ * 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.PortletWindowSession;
+import org.apache.wsrp4j.consumer.driver.GenericPortletSessionImpl;
+import org.apache.wsrp4j.util.Modes;
+import org.apache.wsrp4j.util.WindowStates;
+
+/**
+ * Defines a session object at the consumer-side
+ * to store remote portlet related information that
+ * are needed to interact with the portlet<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 PortletSessionImpl extends GenericPortletSessionImpl {
+
+    /** The logger. */
+    protected final Logger logger;
+
+    /**
+     * constructor
+     * 
+     * @param handle
+     * @param logger
+     */
+    public PortletSessionImpl(String handle, Logger logger) {
+    	super(handle);
+        this.logger = logger;
+    }
+
+    /**
+     * Get the <code>PortletWindowSession</code> of the portlet window with the given ID<br/>
+     * 
+     * @param windowID The ID of the portlet window
+     * @return The <code>PorletWindowSession</code> with the given ID.    
+     **/
+    public PortletWindowSession getPortletWindowSession(String windowID) {
+        SimplePortletWindowSession session = (SimplePortletWindowSession)this.windowSessions.get(windowID);
+        if (session == null) {
+            session = new SimplePortletWindowSessionImpl(windowID, this);
+            session.setMode(Modes._view);
+            session.setWindowState(WindowStates._normal);
+            this.windowSessions.put(windowID, session);
+
+            if ( this.logger.isDebugEnabled() ) {
+            	logger.debug("Created windowSession with ID: " + windowID);
+            }
+        }
+        return session;
+    }
+}

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletSessionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/PortletSessionImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ProducerDescription.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ProducerDescription.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ProducerDescription.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ProducerDescription.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,282 @@
+/*
+ * 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.RegistrationData;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter;
+import org.apache.wsrp4j.consumer.ConsumerEnvironment;
+
+/**
+ * Describes and creates producers.<br/>
+ * If the registration interface url is set (not null) this implies
+ * that the producer requires a registration. If the producer does
+ * not require a registration, set the registration interface url
+ * to null<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 ProducerDescription {
+
+    /** Unique string of the producer */
+    protected String id;
+
+    /** The wsrp makup-interface-url (required) */
+    protected String markupInterfaceUrl;
+
+    /** The wsrp service-description-interface-url (required) */
+    protected String serviceDescriptionInterfaceUrl;
+
+    /** The wsrp registration-interface-url (optional) */
+    protected String registrationInterfaceUrl;
+
+    /** The wsrp portlet-management-interface-url (optional) */
+    protected String portletManagementInterfaceUrl;
+    
+    /** name of the producer */
+    protected String name;
+    
+    /** description of the producer */
+    protected String description;
+
+    /** The registration data. */
+    protected RegistrationData registrationData;
+
+    /**
+     * Default constructor
+     */
+    public ProducerDescription() {
+        this(null);
+    }
+
+    /**
+     * Constructor<br/>
+     * 
+     * @param id of the producer
+     */
+    public ProducerDescription(String id) {
+        this(id, null, null);
+    }
+
+    /**
+     * Constructor<br/>
+     * 
+     * @param id of the producer
+     * @param markupUrl markup-interface-url
+     * @param sdUrl service-description-interface-url
+     */
+    public ProducerDescription(String id, String markupUrl, String sdUrl) {
+        this(id, markupUrl, sdUrl, null, null);
+    }
+
+    /**
+     * Constructor<br/>
+     * 
+     * @param id of the producer
+     * @param markupUrl markup-interface-url
+     * @param sdUrl service-description-interface-url
+     * @param regUrl registration-interface-url
+     * @param pmUrl portlet-management-interface-url
+     */
+    public ProducerDescription(String id, 
+                               String markupUrl, 
+                               String sdUrl,
+                               String regUrl,
+                               String pmUrl) {
+        this.id = id;
+        this.markupInterfaceUrl = markupUrl;
+        this.serviceDescriptionInterfaceUrl = sdUrl;
+        this.registrationInterfaceUrl = regUrl;
+        this.portletManagementInterfaceUrl = pmUrl;
+    }
+
+    /**
+     * @return producer-id
+     */
+    public String getId() {
+        return id;
+    }
+
+    /**
+     * set the producer-id<br/>
+     * 
+     * @param id
+     */
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    /**
+     * @return markup-interface-url
+     */
+    public String getMarkupInterfaceUrl() {
+        return markupInterfaceUrl;
+    }
+
+    /**
+     * set the markup-interface-url<br/>
+     * 
+     * @param markupInterfaceUrl
+     */
+    public void setMarkupInterfaceUrl(String markupInterfaceUrl) {
+        this.markupInterfaceUrl = markupInterfaceUrl;
+    }
+
+    /**
+     * @return portlet-management-interface-url
+     */
+    public String getPortletManagementInterfaceUrl() {
+        return portletManagementInterfaceUrl;
+    }
+
+    /**
+     * Set the portlet-management-interface-url<br/>
+     * 
+     * @param portletManagementInterfaceUrl
+     */
+    public void setPortletManagementInterfaceUrl(String portletManagementInterfaceUrl) {
+        this.portletManagementInterfaceUrl = portletManagementInterfaceUrl;
+    }
+
+    /**
+     * @return registration-interface-url
+     */
+    public String getRegistrationInterfaceUrl() {
+        return registrationInterfaceUrl;
+    }
+
+    /**
+     * Set the registration-interface-url<br/>
+     * 
+     * @param registrationInterfaceUrl
+     */
+    public void setRegistrationInterfaceUrl(String registrationInterfaceUrl) {
+        this.registrationInterfaceUrl = registrationInterfaceUrl;
+    }
+
+    /**
+     * @return service-description-interface-url
+     */
+    public String getServiceDescriptionInterfaceUrl() {
+        return serviceDescriptionInterfaceUrl;
+    }
+
+    /**
+     * Set the service-description-interface-url<br/>
+     * 
+     * @param serviceDescriptionInterfaceUrl
+     */
+    public void setServiceDescriptionInterfaceUrl(String serviceDescriptionInterfaceUrl) {
+        this.serviceDescriptionInterfaceUrl = serviceDescriptionInterfaceUrl;
+    }
+
+    /**
+     * Create a producer description from a configuration<br/>
+     * 
+     * @param config
+     * @return the producer-description
+     * @throws ConfigurationException
+     */
+    public static ProducerDescription fromConfiguration(Configuration config, ConsumerEnvironment env)
+    throws ConfigurationException {
+        final String producerId = config.getAttribute("id");
+        final ProducerDescription desc = new ProducerDescription(producerId);
+
+        desc.setMarkupInterfaceUrl(config.getChild("markup-interface-url").getValue());
+        desc.setServiceDescriptionInterfaceUrl(config.getChild("service-description-interface-url").getValue());
+        desc.setRegistrationInterfaceUrl(config.getChild("registration-interface-url").getValue(null));
+        desc.setPortletManagementInterfaceUrl(config.getChild("portlet-management-interface-url").getValue(null));
+        boolean registrationRequired;
+        if ( desc.getRegistrationInterfaceUrl() != null ) {
+            registrationRequired = config.getChild("registration-interface-url").getAttributeAsBoolean("registration-required", true);
+        } else {
+            registrationRequired = false;
+        }
+        if ( registrationRequired == false ) {
+            desc.setRegistrationInterfaceUrl(null);
+        } else {
+            // get the registration data
+            desc.setRegistrationData(createRegistrationData(config.getChild("registration-data"), env));
+        }
+
+        // optional information
+        desc.setName(config.getChild("name").getValue(null));
+        desc.setDescription(config.getChild("description").getValue(null));
+
+        return desc;
+    }
+
+    public static RegistrationData createRegistrationData(Configuration config,
+                                                          ConsumerEnvironment env) {
+        RegistrationData registrationData = new RegistrationData(
+                env.getConsumerAgent(),
+                env.getSupportedModes(),
+                WSRPAdapter.CONSUMER_URL,  //consumer-name
+                null,         //consumerUserScopes
+                env.getSupportedWindowStates(),
+                null,         //customUserProfileData
+                null,         //extensions
+                false,        //methodGetSupported 
+                null          //registrationProperties
+                );
+        return registrationData;        
+    }
+
+    /**
+     * @return the producer-description as string
+     */
+    public String getDescription() {
+        return description;
+    }
+
+    /**
+     * Set the producer-description<br/>
+     * 
+     * @param description
+     */
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    /**
+     * @return name of the producer
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Set the producer-name<br/>
+     * 
+     * @param name
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public RegistrationData getRegistrationData() {
+        return registrationData;
+    }
+
+    public void setRegistrationData(RegistrationData registrationData) {
+        this.registrationData = registrationData;
+    }
+}

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ProducerDescription.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ProducerDescription.java
------------------------------------------------------------------------------
    svn:keywords = Id