cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r264755 [3/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...
Date Tue, 30 Aug 2005 10:30:18 GMT
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ProducerRegistryImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ProducerRegistryImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ProducerRegistryImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/ProducerRegistryImpl.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,218 @@
+/*
+ * 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 java.util.Map;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter;
+import org.apache.wsrp4j.consumer.ConsumerEnvironment;
+import org.apache.wsrp4j.consumer.Producer;
+import org.apache.wsrp4j.consumer.driver.GenericProducerRegistryImpl;
+import org.apache.wsrp4j.consumer.driver.ProducerImpl;
+import org.apache.wsrp4j.exception.WSRPException;
+
+/**
+ * A producer registry storing all producers in a {@link java.util.Hashtable}
+ * in memory.<br/>
+ * On startup/login the registry is full by the wsrp adapter.
+ *
+ * @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 ProducerRegistryImpl
+    extends GenericProducerRegistryImpl
+    implements LogEnabled, Configurable, RequiresConsumerEnvironment, RequiresWSRPAdapter {
+
+    /** The logger. */
+    protected Logger logger;
+
+    /** The environment. */
+    protected ConsumerEnvironment environment;
+
+    /** All producer descriptions. */
+    protected Map descriptions = new Hashtable();
+
+    /** Initialized? */
+    protected boolean initialized = false;
+
+    /** 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.environment = 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;
+    }
+
+    /**
+     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+     */
+    public void configure(Configuration c) throws ConfigurationException {
+        if ( c != null ) {
+            Configuration config = c.getChild("producers", true);
+            // create a list of descriptions
+            Configuration[] children = config.getChildren("producer");
+            for(int i=0; i<children.length; i++) {
+                final Configuration current = children[i];
+                final ProducerDescription desc = ProducerDescription.fromConfiguration(current, this.environment);
+                this.descriptions.put(desc.getId(), desc);
+            }
+        }
+    }
+
+    /**
+     * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
+     */
+    public void enableLogging(Logger newLogger) {
+        this.logger = newLogger;
+    }
+
+    /**
+     * 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;
+                    try {
+                        this.configure(this.adapter.getWsrpConfiguration());
+                    } catch (ConfigurationException ce) {
+                        this.logger.error("Unable to read wsrp configuration.", ce);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Add a new producer<br/>
+     * 
+     * @param desc The producer description.
+     * @return Returns true if the producer could be added.
+     */
+    public boolean addProducer(ProducerDescription desc) {
+        this.checkInitialized();
+        try {
+            final Producer producer = new ProducerImpl(desc.getId(),
+                                        desc.getMarkupInterfaceUrl(),
+                                        desc.getServiceDescriptionInterfaceUrl(),
+                                        desc.getRegistrationInterfaceUrl(),
+                                        desc.getPortletManagementInterfaceUrl(),
+                                        desc.getRegistrationData());
+            producer.setName(desc.getName());
+            producer.setDescription(desc.getDescription());
+            this.addProducer(producer);
+            return true;
+        } catch (WSRPException we) {
+            this.logger.error("Unable to add wsrp producer: " + desc.getId()
+                            + " - Continuing without configured producer.", we);
+            return false;
+        }
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.ProducerRegistry#addProducer(org.apache.wsrp4j.consumer.Producer)
+     */
+    public void addProducer(Producer producer) {
+        this.checkInitialized();
+        // remove the description
+        this.descriptions.remove(producer.getID());
+        super.addProducer(producer);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.ProducerRegistry#existsProducer(java.lang.String)
+     */
+    public boolean existsProducer(String id) {
+        this.checkInitialized();
+        if ( this.descriptions.containsKey(id) ) {
+            return true;
+        }
+        return super.existsProducer(id);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.ProducerRegistry#getAllProducers()
+     */
+    public Iterator getAllProducers() {
+        this.checkInitialized();
+        // create all producers from pending descriptions
+        if ( this.descriptions.size() > 0 ) {
+            final Iterator i = this.descriptions.values().iterator();
+            while ( i.hasNext() ) {
+                final ProducerDescription desc = (ProducerDescription)i.next();
+                this.addProducer(desc);
+            }
+            this.descriptions.clear();
+        }
+        return super.getAllProducers();
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.ProducerRegistry#getProducer(java.lang.String)
+     */
+    public Producer getProducer(String id) {
+        this.checkInitialized();
+        // create pending description
+        ProducerDescription desc = (ProducerDescription)this.descriptions.remove(id);
+        if ( desc != null ) {
+            this.addProducer(desc);
+        }
+        return super.getProducer(id);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.ProducerRegistry#removeAllProducers()
+     */
+    public void removeAllProducers() {
+        this.checkInitialized();
+        this.descriptions.clear();
+        super.removeAllProducers();
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.ProducerRegistry#removeProducer(java.lang.String)
+     */
+    public Producer removeProducer(String id) {
+        this.checkInitialized();
+        // unfortunately we have to return the producer, so
+        // we have to create a pending producer first just
+        // to be able to remove it later on
+        if ( this.descriptions.containsKey(id) ) {
+            this.getProducer(id);
+        }
+        return super.removeProducer(id);
+    }
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/Request.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/Request.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/Request.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/Request.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,68 @@
+/*
+ * 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.NamedString;
+
+/**
+ * Defines a request from the end-user to the swing consumer as result
+ * of an interaction (e.g. click on hyperlink) of the end-user with the 
+ * representation of a remote portlet.<br/> 
+ *
+ * Due to the two phase protocol of WSRP this request carries information
+ * which need to be passed back to the producer in order to process the 
+ * interaction at the producer-side.<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 interface Request {
+
+    /**
+     * Set the interaction state of a portlet which should be passed 
+     * to the producer.
+     * 
+     * @param state the interaction state of a portlet
+     **/
+    void setInteractionState(String state);
+
+    /**
+     * Get the interaction state of the portlet.
+     * 
+     * @return interaction state of a portlet carried in a request
+     **/
+    String getInteractionState();
+
+    /**
+     * Add any parameters to the request. These parameters should
+     * be carried in the form parameters field of WSRP.
+     * 
+     * @param name The key which identifies the parameter
+     * @param value The value of the parameter
+     **/
+    void addFormParameter(String name, String value);
+
+    /**
+     * Get all form parameters from the request. The returned
+     * <code>NamedString</code> array contains all parameter key/value pairs
+     * and can directly be passed to the form parameter field in WSRP.
+     *
+     * @return Array with all set parameters
+     **/
+    NamedString[] getFormParameters();
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequestImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequestImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequestImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequestImpl.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,103 @@
+/*
+ * 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.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import oasis.names.tc.wsrp.v1.types.NamedString;
+
+/**
+ * This class implements the Request interface and used by 
+ * the swing consumer to store request related information. 
+ * 
+ * @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 RequestImpl implements Request {
+
+    /** Map to store all form params. */
+    protected Map formParameters;
+
+    /** interaction state. */
+    protected String interactionState;
+
+	/**
+	 * Default constructor	  	
+	 **/
+    public RequestImpl() {
+        this.formParameters = new HashMap();
+    }
+	
+	/**
+	* Add any parameters to the request. These parameters should
+	* be carried in the form parameters field of WSRP.
+	* 
+	* @param name The key which identifies the parameter
+	* @param value The value of the parameter
+	**/
+    public void addFormParameter(String name, String value) {
+        this.formParameters.put(name, value);
+    }
+	
+	/**
+	 * Get all form parameters from the request. The returned
+	 * <code>NamedString</code> array contains all parameter key/value pairs
+	 * and can directly be passed to the form parameter field in WSRP.
+	 *
+	 * @return Array with all set parameters
+	 **/
+    public NamedString[] getFormParameters() {
+        ArrayList paramList = new ArrayList();
+        Iterator params = this.formParameters.keySet().iterator();
+        while (params.hasNext()) {
+            String name = (String)params.next();
+
+            NamedString parameter = new NamedString();
+            parameter.setName(name);
+            parameter.setValue((String)this.formParameters.get(name));
+            paramList.add(parameter);
+        }
+        
+        NamedString[] formParams = new NamedString[paramList.size()];
+        paramList.toArray(formParams);
+
+        return formParams;
+    }
+
+	/**
+	 * Set the interaction state of a portlet which should be passed 
+	 * to the producer.
+	 * 
+	 * @param state the interaction state of a portlet
+	 **/
+    public void setInteractionState(String state) {
+        this.interactionState = state;
+    }
+	
+	/**
+	* Get the interaction state of the portlet.
+	* 
+	* @return interaction state of a portlet carried in a request
+	**/
+    public String getInteractionState() {
+        return this.interactionState;
+    }
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequiresConsumerEnvironment.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequiresConsumerEnvironment.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequiresConsumerEnvironment.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequiresConsumerEnvironment.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,28 @@
+/*
+ * 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.wsrp4j.consumer.ConsumerEnvironment;
+
+/**
+ * This interface marks a component if the component needs a reference to consumer environment.
+ *
+ * @version $Id$
+ **/
+public interface RequiresConsumerEnvironment {
+
+    void setConsumerEnvironment(ConsumerEnvironment env);
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequiresPortalService.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequiresPortalService.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequiresPortalService.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequiresPortalService.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,29 @@
+/*
+ * 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.cocoon.portal.PortalService;
+
+/**
+ * This interface marks a component if the component needs a reference to the
+ * portal service.
+ *
+ * @version $Id$
+ **/
+public interface RequiresPortalService {
+
+    void setPortalService(PortalService service);
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequiresWSRPAdapter.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequiresWSRPAdapter.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequiresWSRPAdapter.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/RequiresWSRPAdapter.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,28 @@
+/*
+ * 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.cocoon.portal.wsrp.adapter.WSRPAdapter;
+
+/**
+ * This interface marks a component if the component needs a reference to the WSRP adapter.
+ *
+ * @version $Id$
+ **/
+public interface RequiresWSRPAdapter {
+
+    void setWSRPAdapter(WSRPAdapter adapter);
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/SessionHandlerImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/SessionHandlerImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/SessionHandlerImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/SessionHandlerImpl.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,97 @@
+/*
+ * 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 org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.wsrp4j.consumer.ConsumerEnvironment;
+import org.apache.wsrp4j.consumer.SessionHandler;
+import org.apache.wsrp4j.consumer.UserSession;
+import org.apache.wsrp4j.consumer.UserSessionMgr;
+import org.apache.wsrp4j.exception.WSRPException;
+
+/**
+ * Simple Session Handler<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 SessionHandlerImpl
+    extends AbstractLogEnabled
+    implements SessionHandler, RequiresConsumerEnvironment {
+
+    /** Holds all user-sessions */
+    protected Hashtable userSessions = new Hashtable();
+    
+    /** The consumerEnvironment */
+    protected ConsumerEnvironment consumerEnv;
+	
+	/**
+	 * @see org.apache.cocoon.portal.wsrp.consumer.RequiresConsumerEnvironment#setConsumerEnvironment(org.apache.wsrp4j.consumer.ConsumerEnvironment)
+	 */
+	public void setConsumerEnvironment(ConsumerEnvironment env) {
+        this.consumerEnv = env;
+    }
+
+    /**
+	 * Get the session manager of the user session with the given user ID and producer ID<br/>
+	 * 
+	 * @return The user session object representing a session between an end-user and
+	 *         a producer.
+	 **/
+    public UserSessionMgr getUserSession(String producerID, String userID)
+    throws WSRPException {
+        UserSessionMgr userSession = null;
+
+        if (producerID != null && userID != null) {
+            String key = createKey(userID, producerID);
+            userSession = (UserSessionMgr)this.userSessions.get(key);
+
+            if (userSession == null) {
+                String url = consumerEnv.getProducerRegistry().getProducer(producerID).getMarkupInterfaceEndpoint();
+                userSession = new UserSessionImpl(producerID, userID, url, this.getLogger());
+                addUserSession(userSession);
+            }
+        }
+
+        return userSession;
+    }
+
+    /**
+     * Set the Session into the sessionHandler
+     * 
+     * @param userSession
+     */
+    private void addUserSession(UserSession userSession) {
+        if (userSession != null) {
+            this.userSessions.put(createKey(userSession.getUserID(), userSession.getProducerID()), userSession);
+        }
+    }
+
+    /**
+     * Represents the values of the user and the producer in a nice form<br/>
+     * 
+     * @param userID
+     * @param producerID
+     * @return the string containing information of the user and the producer
+     */
+    private String createKey(String userID, String producerID) {
+        return "user :" + userID + " producer:" + producerID;
+    }
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/SimplePortletWindowSession.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/SimplePortletWindowSession.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/SimplePortletWindowSession.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/SimplePortletWindowSession.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,75 @@
+/*
+ * 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.wsrp4j.consumer.PortletWindowSession;
+
+/**
+ * Defines a portlet window session used by the cocoon portal
+ * In additional to <code>SimplePortletWindowSession</code>
+ * it contains information about the current window state and mode of a portlet window.<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 interface SimplePortletWindowSession extends PortletWindowSession {
+
+	/**
+	 * Get the window state of the portlet window 
+	 * this session belongs to.<br/>
+	 * 
+	 * @return the window state
+	 **/
+	String getWindowState();
+
+	/**
+	 * Set the window state of the portlet window
+	 * this session belongs to.<br/>
+	 * 
+	 * @param windowState The window state
+	 **/
+	void setWindowState(String windowState);
+
+	/**
+	 * Get the portlet mode of the portlet window.<br/>
+	 * 
+	 * @return The portlet mode 
+	 **/
+	String getMode();
+
+	/**
+	 * Set the portlet mode of the portlet window.<br/>
+	 * 
+	 * @param mode The portlet mode
+	 **/
+	void setMode(String mode);
+	
+	/**
+	 * Get the navigational state for the portlet window the session belongs to<br/>
+     * 
+	 * @return the navigational state
+	 **/
+	String getNavigationalState();
+	
+	/**
+	 * Set the navigational state for the portlet window the session belongs to<br/>
+     * 
+	 * @param navState the navigational state
+	 **/
+	void setNavigationalState(String navState);
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/SimplePortletWindowSessionImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/SimplePortletWindowSessionImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/SimplePortletWindowSessionImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/SimplePortletWindowSessionImpl.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,109 @@
+/*
+ * 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.wsrp4j.consumer.PortletSession;
+import org.apache.wsrp4j.consumer.driver.GenericPortletWindowSessionImpl;
+
+/**
+ * Holds the parameters for displaying the portlet in a portlet-window.<br/>
+ * The attributes <tt>windowState</tt>, <tt>portletMode</tt> and the navigationalState
+ * are representing all preferences of the portlet-window. <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 SimplePortletWindowSessionImpl
+    extends GenericPortletWindowSessionImpl
+    implements SimplePortletWindowSession {
+
+    /** The windowState the portlet has (minimized, normal, maximized)
+     * @see org.apache.wsrp4j.util.Constants */
+	private String windowState;
+
+    /** The portletMode the portlet has (minimized, normal, maximized)
+     * @see org.apache.wsrp4j.util.Constants */
+	private String mode;
+
+    /** The navigationalState of the portlet */
+	private String navState;
+
+	/**
+     * Constructor
+     * 
+	 * @param windowID
+	 * @param pSession
+	 */
+	public SimplePortletWindowSessionImpl(
+		String windowID,
+		PortletSession pSession) {
+		super(windowID, pSession);
+	}
+   
+	/**
+	 * Get the window state of the portlet window 
+	 * this session belongs to<br/>  
+	 * 
+	 * @return the window state
+	 **/
+	public String getWindowState() {
+		return windowState;
+	}
+
+   /**
+	* Get the portlet mode<br/>
+	* 
+	* @return The portlet mode of the portlet window.
+	**/
+	public String getMode()	{
+		return mode;
+	}
+
+	/**
+	 * Set the window state of the portlet instance
+	 * this session belongs to<br/>
+	 * 
+	 * @param windowState The window state  of the portlet window
+	 **/
+	public void setWindowState(String windowState) {
+		this.windowState = windowState;
+	}
+
+	/**
+	 * Set the portlet mode<br/>
+	 * 
+	 * @param mode The portlet mode of the portlet window
+	 **/
+	public void setMode(String mode) {
+		this.mode = mode;
+	}
+	
+	/**
+	 * @see org.apache.cocoon.portal.wsrp.consumer.SimplePortletWindowSession#getNavigationalState()
+	 */
+	public String getNavigationalState() {
+		return navState;
+	}
+
+	/**
+	 * @see org.apache.cocoon.portal.wsrp.consumer.SimplePortletWindowSession#setNavigationalState(java.lang.String)
+	 */
+	public void setNavigationalState(String navState) {
+		this.navState = navState;
+	}
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/URLGeneratorImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/URLGeneratorImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/URLGeneratorImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/URLGeneratorImpl.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,151 @@
+/*
+ * 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.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.coplet.CopletInstanceData;
+import org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter;
+import org.apache.cocoon.portal.wsrp.adapter.WSRPEventAspect;
+import org.apache.wsrp4j.consumer.URLGenerator;
+import org.apache.wsrp4j.util.Constants;
+
+/**
+ * Implements the URLGenerator interface providing methods
+ * to query the consumer's urls.
+ *
+ * @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 URLGeneratorImpl
+    implements URLGenerator, RequiresPortalService, RequiresWSRPAdapter {
+
+    /** The portal service. */
+    protected PortalService service;
+
+    /** The WSRP Adapter. */
+    protected WSRPAdapter adapter;
+
+    /**
+     * @see org.apache.cocoon.portal.wsrp.consumer.RequiresWSRPAdapter#setWSRPAdapter(org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter)
+     */
+    public void setWSRPAdapter(WSRPAdapter adapter) {
+        this.adapter = adapter;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.wsrp.consumer.RequiresPortalService#setPortalService(org.apache.cocoon.portal.PortalService)
+     */
+    public void setPortalService(PortalService service) {
+        this.service = service;
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLGenerator#getBlockingActionURL(java.util.Map)
+     */
+    public String getBlockingActionURL(Map params) {
+        return this.generateUrl(params);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLGenerator#getRenderURL(java.util.Map)
+     */
+    public String getRenderURL(Map params) {
+        return this.generateUrl(params);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLGenerator#getResourceURL(java.util.Map)
+     */
+    public String getResourceURL(Map params) {
+        // this is a little bit tricky
+        // we create a usual portal link first with
+        // all the infos
+        String portalLink = this.generateUrl(params);
+        
+        // now we replace the portal pipeline with
+        // the resource pipeline
+        int linkEndPos = portalLink.indexOf('?');
+        int pipelineStartPos = portalLink.lastIndexOf('/', linkEndPos);
+
+        StringBuffer buffer = new StringBuffer();
+        buffer.append(portalLink.substring(0, pipelineStartPos+1));
+        buffer.append("wsrprsc");
+        buffer.append(portalLink.substring(linkEndPos));
+        return buffer.toString(); 
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLGenerator#getNamespacedToken(java.lang.String)
+     */
+    public String getNamespacedToken(String token) {
+        final CopletInstanceData coplet = this.adapter.getCurrentCopletInstanceData();
+        return coplet.getId();
+    }
+
+    /**
+     * Generate the url.<br/>
+     * We simply create a new wsrp event and use the portal link service.<br/>
+     * 
+     * @param params Url-parameters
+     * @return portal-url including all required attributes
+     */
+    protected String generateUrl(Map params) {
+        if ( params == null ) {
+            params = new HashMap();
+        }
+        Boolean secureLink = null;
+        if ( "true".equalsIgnoreCase((String)params.get(Constants.SECURE_URL)) ) { 
+            secureLink = Boolean.TRUE;
+        }
+        final CopletInstanceData coplet = this.adapter.getCurrentCopletInstanceData();
+        params.put(WSRPEventAspect.REQUEST_PARAMETER_NAME, coplet.getId());
+        final StringBuffer buffer = new StringBuffer(this.service.getComponentManager().getLinkService().getRefreshLinkURI(secureLink));
+        boolean hasParams = buffer.indexOf("?") > 0;
+        Iterator i = params.entrySet().iterator();
+        while ( i.hasNext() ) {
+            final Map.Entry entry = (Map.Entry)i.next();
+            if ( hasParams ) {
+                buffer.append('&');
+            } else {
+                hasParams = true;
+                buffer.append('?');
+            }
+            buffer.append(entry.getKey()).append('=').append(entry.getValue());
+        }
+        // append consumer parameters
+        Map consumerParameters = (Map)coplet.getTemporaryAttribute(WSRPAdapter.ATTRIBUTE_NAME_CONSUMER_MAP);
+        if ( consumerParameters != null ) {
+            i = consumerParameters.entrySet().iterator();
+            while (i.hasNext()) {
+                final Map.Entry entry = (Map.Entry)i.next();
+                if ( hasParams ) {
+                    buffer.append('&');
+                } else {
+                    hasParams = true;
+                    buffer.append('?');
+                }
+                buffer.append(entry.getKey()).append('=').append(entry.getValue());
+            }
+        }
+        return buffer.toString();
+    }
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/URLRewriterImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/URLRewriterImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/URLRewriterImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/URLRewriterImpl.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,219 @@
+/*
+ * 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.HashMap;
+import java.util.Map;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.wsrp4j.consumer.URLGenerator;
+import org.apache.wsrp4j.consumer.URLRewriter;
+import org.apache.wsrp4j.util.Constants;
+
+/**
+ * Implements the URLRewriter interface providing a method
+ * to rewrite urls (Consumer URL Rewriting).<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 URLRewriterImpl
+    extends AbstractLogEnabled
+    implements URLRewriter {
+
+    /** The url generator. */
+    protected URLGenerator urlGenerator;
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLRewriter#setURLGenerator(org.apache.wsrp4j.consumer.URLGenerator)
+     */
+    public void setURLGenerator(URLGenerator urlGenerator) {
+        this.urlGenerator = urlGenerator;
+    }
+
+    /**
+     * Rewriting: get url from URLGenerator and append it<br/>
+     * 
+     * @param markup
+     * @param rewriteURL
+     */
+    protected void rewrite(StringBuffer markup, String rewriteURL) {
+    	if ( rewriteURL.startsWith(Constants.REWRITE_START + Constants.PARAMS_START) ) {
+    		// handle URL rewriting        		
+			Map params = createParameterMap(rewriteURL);
+
+			// What kind of link has to be rewritten?
+			if (rewriteURL.indexOf(Constants.URL_TYPE_BLOCKINGACTION) != -1) {
+                markup.append(urlGenerator.getBlockingActionURL(params));
+			} else if (rewriteURL.indexOf(Constants.URL_TYPE_RENDER) != -1) {
+				markup.append(urlGenerator.getRenderURL(params));
+			} else if (rewriteURL.indexOf(Constants.URL_TYPE_RESOURCE) != -1) {
+				markup.append(urlGenerator.getResourceURL(params));
+			}
+    	} else if (rewriteURL.startsWith(Constants.REWRITE_START + Constants.NAMESPACE_START) ) {
+    		markup.append(urlGenerator.getNamespacedToken(""));
+    	} else {
+            this.getLogger().error("No valid rewrite expression found in: " + rewriteURL);
+    	}
+    }
+
+    /**
+     * Extracts parameters from url to be rewritten copies them into a map.<br/>
+     * 
+     * @param rewriteURL
+     * @return Map
+     */
+    protected Map createParameterMap(String rewriteURL) {
+
+        Map params = new HashMap();
+
+        if (rewriteURL.indexOf(Constants.URL_TYPE_BLOCKINGACTION) != -1) {
+            params.put(Constants.URL_TYPE, Constants.URL_TYPE_BLOCKINGACTION);
+        } else if (rewriteURL.indexOf(Constants.URL_TYPE_RENDER) != -1) {
+            params.put(Constants.URL_TYPE, Constants.URL_TYPE_RENDER);
+        } else if (rewriteURL.indexOf(Constants.URL_TYPE_RESOURCE) != -1) {
+            params.put(Constants.URL_TYPE, Constants.URL_TYPE_RESOURCE);
+        } else {
+            this.getLogger().error("no valid url-type: " + rewriteURL);
+        }
+
+        // begin parsing
+        int equals = 0;
+        int next = 0;
+        int end = rewriteURL.indexOf(Constants.REWRITE_END);
+        int index = rewriteURL.indexOf(Constants.NEXT_PARAM);
+        int lengthNext = 0;
+        String subNext = null;
+
+        while (index != -1) {
+			// support "&amp;" as parameter seperator
+			// see if &amp; was used
+			subNext = rewriteURL.substring(index, index + Constants.NEXT_PARAM_AMP.length());
+			if (subNext.equals(Constants.NEXT_PARAM_AMP)) {
+				lengthNext = Constants.NEXT_PARAM_AMP.length();
+			}
+			else {
+				lengthNext = Constants.NEXT_PARAM.length();
+			}
+			 
+            equals = rewriteURL.indexOf(Constants.EQUALS, index + lengthNext);
+            next = rewriteURL.indexOf(Constants.NEXT_PARAM, equals);
+
+            if (equals != -1) {
+                if (next != -1) {
+                    params.put(rewriteURL.substring(index + lengthNext, equals), rewriteURL.substring(equals + 1, next));
+                } else {
+                    params.put(rewriteURL.substring(index + lengthNext, equals), rewriteURL.substring(equals + 1, end));
+                }
+            }
+            index = next;
+        }
+
+        return params;
+
+    }
+
+    /**
+     * Parses markup and performs URL rewriting.<br/>
+     *
+     * Principle:<br/>
+     * - Iterate over markup-string once and copy processed markup to result
+     *   buffer (StringBuffer)<br/>
+     * - If url to be rewritten found (during markup iteration),<br/>
+     *   ... append markup before url to result buffer,<br/>
+     *   ... perform rewriting (call URLGenerator) and append rewritten url to result buffer.<br/>
+     *
+     * Incomplete rewrite-pairs (e.g. a rewrite-begin-token not followed by a
+     * rewrite-end-token) are considered as 'normal' markup.<br/>
+     *
+     * @param markup String representing the markup to be processed.
+     *
+     * @return String representing the processed markup.
+     *    
+	 * @see org.apache.wsrp4j.consumer.URLRewriter#rewriteURLs(java.lang.String)
+	 */
+	public String rewriteURLs(String markup) {
+		StringBuffer resultMarkup = new StringBuffer("");
+		int markupIndex = 0;
+		int rewriteStartPos = -1;
+		int rewriteEndPos = -1;
+		int currentPos = 0;
+		String exprType = null;
+		
+		// loop through the markup, find rewrite expressions, rewrite them 
+		while ( markupIndex < markup.length() ) {
+			rewriteStartPos = -1;
+			rewriteEndPos = -1;
+
+			// get fist occurance of wsrp rewrite expression
+			rewriteStartPos = markup.indexOf(Constants.REWRITE_START,markupIndex);
+			
+			if (! ( rewriteStartPos == -1 ||
+					( rewriteStartPos + Constants.REWRITE_START.length() - 1 ) >
+					( markup.length() - 2 ) ) ) {
+				// found a rewrite start token, and token is not at the end of markup so we can
+				// determine the rewrite type, i.e. there is at least 1 char after the rewrite start token
+					
+				// namespace or URL? The single char string after the token decides
+				exprType = markup.substring(rewriteStartPos+Constants.REWRITE_START.length() - 1 + 1,
+				   						    rewriteStartPos+Constants.REWRITE_START.length() - 1 + 2);
+			
+				if ( exprType.equals(Constants.NAMESPACE_START)) {
+					// ok, we have a namespace rewrite here						
+					rewriteEndPos = rewriteStartPos + Constants.REWRITE_START.length()
+									+ Constants.NAMESPACE_START.length() - 1;
+				} else if ( exprType.equals(Constants.PARAMS_START) ) {
+					// ok, we have a URL rewrite here
+					// get the position of the end token
+					rewriteEndPos = markup.indexOf(Constants.REWRITE_END,markupIndex);
+					if (rewriteEndPos != -1) {
+						// now let's see if we find a rewrite start token nearer to the end token
+						currentPos = rewriteStartPos;
+
+						while ((currentPos != -1) && (currentPos < rewriteEndPos)) {
+							 // update rewriteStartPos with position of found rewrite begin token being 'nearer' 
+							rewriteStartPos = currentPos;
+							// look for next URL rewrite start expression
+							currentPos = markup.indexOf(Constants.REWRITE_START+Constants.PARAMS_START,
+														rewriteStartPos + Constants.REWRITE_START.length()
+														+ Constants.PARAMS_START.length());
+						}
+						rewriteEndPos = rewriteEndPos + Constants.REWRITE_END.length() - 1;
+					}
+				}
+			}
+			
+			if ( (rewriteStartPos != -1) && (rewriteEndPos != -1) ) {
+				// append markup before rewrite expression
+				resultMarkup.append(markup.substring(markupIndex,rewriteStartPos));
+				// append rewritten expression
+				rewrite(resultMarkup,markup.substring(rewriteStartPos,rewriteEndPos+1));
+				// set markup index after the last char of the rewriteExpression
+				markupIndex = rewriteEndPos + 1;
+			} else {
+				// append rest of markup
+				resultMarkup.append(markup.substring(markupIndex,markup.length()));
+				markupIndex = markup.length();
+			}
+		}
+
+		return resultMarkup.toString();
+	}
+}
+
+

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/URLTemplateComposerImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/URLTemplateComposerImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/URLTemplateComposerImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/URLTemplateComposerImpl.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,440 @@
+/*
+ * 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.cocoon.portal.coplet.CopletInstanceData;
+import org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter;
+import org.apache.wsrp4j.consumer.URLGenerator;
+import org.apache.wsrp4j.consumer.URLTemplateComposer;
+import org.apache.wsrp4j.util.Constants;
+
+/**
+ * Implements the {@link org.apache.wsrp4j.consumer.URLTemplateComposer} interface
+ * providing methods to generate URL templates.<br/>
+ * The generated templates will be transmitted to producers (or respectively portlets)
+ * that are willing to properly write URLs for a consumer. (With templates the consumer
+ * indicates how it needs URLs formatted in order to process them properly.)
+ *
+ * @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 URLTemplateComposerImpl
+    implements URLTemplateComposer, RequiresWSRPAdapter {
+
+    /** The url generator. */
+    protected URLGenerator urlGenerator;
+
+    /** The wsrp adapter. */
+    protected WSRPAdapter adapter;
+
+    /**
+     * @see org.apache.cocoon.portal.wsrp.consumer.RequiresWSRPAdapter#setWSRPAdapter(org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter)
+     */
+    public void setWSRPAdapter(WSRPAdapter adapter) {
+        this.adapter = adapter;
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLTemplateComposer#setURLGenerator(org.apache.wsrp4j.consumer.URLGenerator)
+     */
+    public void setURLGenerator(URLGenerator urlGenerator) {
+        this.urlGenerator = urlGenerator;
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLTemplateComposer#createBlockingActionTemplate(boolean, boolean, boolean, boolean)
+     */
+    public String createBlockingActionTemplate(boolean includePortletHandle,
+                                               boolean includeUserContextKey,
+                                               boolean includePortletInstanceKey,
+                                               boolean includeSessionID) {
+
+        return createTemplate(
+                    urlGenerator.getBlockingActionURL(null),
+                    true,
+                    true,
+                    true,
+                    true,
+                    true,
+                    false,
+                    false,
+                    false,
+                    includePortletHandle,
+                    includeUserContextKey,
+                    includePortletInstanceKey,
+                    includeSessionID);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLTemplateComposer#createSecureBlockingActionTemplate(boolean, boolean, boolean, boolean)
+     */
+    public String createSecureBlockingActionTemplate(boolean includePortletHandle,
+                                                     boolean includeUserContextKey,
+                                                     boolean includePortletInstanceKey,
+                                                     boolean includeSessionID) {
+        return createTemplate(
+                    urlGenerator.getBlockingActionURL(null),
+                    true,
+                    true,
+                    true,
+                    true,
+                    true,
+                    true,
+                    false,
+                    false,
+                    includePortletHandle,
+                    includeUserContextKey,
+                    includePortletInstanceKey,
+                    includeSessionID);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLTemplateComposer#createRenderTemplate(boolean, boolean, boolean, boolean)
+     */
+    public String createRenderTemplate(boolean includePortletHandle,
+                                       boolean includeUserContextKey,
+                                       boolean includePortletInstanceKey,
+                                       boolean includeSessionID) {
+        return createTemplate(
+                    urlGenerator.getRenderURL(null),
+                    true,
+                    true,
+                    true,
+                    true,
+                    true,
+                    false,
+                    false,
+                    false,
+                    includePortletHandle,
+                    includeUserContextKey,
+                    includePortletInstanceKey,
+                    includeSessionID);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLTemplateComposer#createSecureRenderTemplate(boolean, boolean, boolean, boolean)
+     */
+    public String createSecureRenderTemplate(boolean includePortletHandle,
+                                             boolean includeUserContextKey,
+                                             boolean includePortletInstanceKey,
+                                             boolean includeSessionID) {
+        return createTemplate(
+                    urlGenerator.getRenderURL(null),
+                    true,
+                    true,
+                    true,
+                    true,
+                    true,
+                    true,
+                    false,
+                    false,
+                    includePortletHandle,
+                    includeUserContextKey,
+                    includePortletInstanceKey,
+                    includeSessionID);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLTemplateComposer#createResourceTemplate(boolean, boolean, boolean, boolean)
+     */
+    public String createResourceTemplate(boolean includePortletHandle,
+                                         boolean includeUserContextKey,
+                                         boolean includePortletInstanceKey,
+                                         boolean includeSessionID) {
+        return createTemplate(
+                    urlGenerator.getResourceURL(null),
+                    true,
+                    false,
+                    false,
+                    false,
+                    false,
+                    false,
+                    true,
+                    true,
+                    includePortletHandle,
+                    includeUserContextKey,
+                    includePortletInstanceKey,
+                    includeSessionID);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLTemplateComposer#createSecureResourceTemplate(boolean, boolean, boolean, boolean)
+     */
+    public String createSecureResourceTemplate(boolean includePortletHandle,
+                                               boolean includeUserContextKey,
+                                               boolean includePortletInstanceKey,
+                                               boolean includeSessionID) {
+        return  createTemplate(
+                    urlGenerator.getResourceURL(null),
+                    true,
+                    false,
+                    false,
+                    false,
+                    false,
+                    true,
+                    true,
+                    true,
+                    includePortletHandle,
+                    includeUserContextKey,
+                    includePortletInstanceKey,
+                    includeSessionID);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLTemplateComposer#createDefaultTemplate(boolean, boolean, boolean, boolean)
+     */
+    public String createDefaultTemplate(boolean includePortletHandle,
+                                        boolean includeUserContextKey,
+                                        boolean includePortletInstanceKey,
+                                        boolean includeSessionID) {
+        return createTemplate(
+                    urlGenerator.getRenderURL(null),
+                    true,
+                    true,
+                    true,
+                    true,
+                    true,
+                    false,
+                    true,
+                    true,
+                    includePortletHandle,
+                    includeUserContextKey,
+                    includePortletInstanceKey,
+                    includeSessionID);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLTemplateComposer#createSecureDefaultTemplate(boolean, boolean, boolean, boolean)
+     */
+    public String createSecureDefaultTemplate(boolean includePortletHandle,
+                                              boolean includeUserContextKey,
+                                              boolean includePortletInstanceKey,
+                                              boolean includeSessionID) {
+        return createTemplate(
+                    urlGenerator.getRenderURL(null),
+                    true,
+                    true,
+                    true,
+                    true,
+                    true,
+                    true,
+                    true,
+                    true,
+                    includePortletHandle,
+                    includeUserContextKey,
+                    includePortletInstanceKey,
+                    includeSessionID);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.consumer.URLTemplateComposer#getNamespacePrefix()
+     */
+    public String getNamespacePrefix() {
+        final CopletInstanceData coplet = this.adapter.getCurrentCopletInstanceData();
+        return coplet.getId();
+    }
+
+    /**
+     * creates the url for the producer<br/>
+     * 
+     * @param url
+     * @param needsURLType
+     * @param needsPortletMode
+     * @param needsNavState
+     * @param needsInteractionState
+     * @param needsWinState
+     * @param needsSecURL
+     * @param needsURL
+     * @param needsRewriteResource
+     * @param needsPortletHandle
+     * @param needsUserContextKey
+     * @param needsPortletInstanceKey
+     * @param needsSessionID
+     * @return url for the producer
+     */
+    protected String createTemplate(String url,
+                                    boolean needsURLType,
+                                    boolean needsPortletMode,
+                                    boolean needsNavState,
+                                    boolean needsInteractionState,
+                                    boolean needsWinState,
+                                    boolean needsSecURL,
+                                    boolean needsURL,
+                                    boolean needsRewriteResource,
+                                    boolean needsPortletHandle,
+                                    boolean needsUserContextKey,
+                                    boolean needsPortletInstanceKey,
+                                    boolean needsSessionID) {
+
+        StringBuffer template = new StringBuffer();
+        StringBuffer remainder = null;
+
+        boolean isFirstParam = true;
+        int index;
+
+        // check if url already contains parameters
+        if ((index = url.indexOf(Constants.PARAMS_START)) != -1) {
+            template.append(url.substring(0, index));
+            remainder = new StringBuffer(url.substring(index + 1));
+        } else {
+            template.append(url.toString());
+        }
+
+        if (needsURLType) {
+            if (isFirstParam) {
+                template.append(Constants.PARAMS_START);
+                isFirstParam = false;
+            }
+            template.append(insertPair(Constants.URL_TYPE));
+        }
+
+        if (needsPortletMode) {
+            if (isFirstParam) {
+                template.append(Constants.PARAMS_START);
+                isFirstParam = false;
+            } else {
+                template.append(Constants.NEXT_PARAM);
+            }
+            template.append(insertPair(Constants.PORTLET_MODE));
+        }
+
+        if (needsNavState) {
+            if (isFirstParam) {
+                template.append(Constants.PARAMS_START);
+                isFirstParam = false;
+            } else {
+                template.append(Constants.NEXT_PARAM);
+            }
+            template.append(insertPair(Constants.NAVIGATIONAL_STATE));
+        }
+
+        if (needsInteractionState) {
+            if (isFirstParam) {
+                template.append(Constants.PARAMS_START);
+                isFirstParam = false;
+            } else {
+                template.append(Constants.NEXT_PARAM);
+            }
+            template.append(insertPair(Constants.INTERACTION_STATE));
+        }
+
+        if (needsWinState) {
+            if (isFirstParam) {
+                template.append(Constants.PARAMS_START);
+                isFirstParam = false;
+            } else {
+                template.append(Constants.NEXT_PARAM);
+            }
+            template.append(insertPair(Constants.WINDOW_STATE));
+        }
+
+        if (needsSecURL) {
+            if (isFirstParam) {
+                template.append(Constants.PARAMS_START);
+                isFirstParam = false;
+            } else {
+                template.append(Constants.NEXT_PARAM);
+            }
+            template.append(insertPair(Constants.SECURE_URL));
+        }
+
+        if (needsURL) {
+            if (isFirstParam) {
+                template.append(Constants.PARAMS_START);
+                isFirstParam = false;
+            } else {
+                template.append(Constants.NEXT_PARAM);
+            }
+            template.append(insertPair(Constants.URL));
+        }
+
+        if (needsRewriteResource) {
+            if (isFirstParam) {
+                template.append(Constants.PARAMS_START);
+                isFirstParam = false;
+            } else {
+                template.append(Constants.NEXT_PARAM);
+            }
+            template.append(insertPair(Constants.REWRITE_RESOURCE));
+        }
+
+        if (needsPortletHandle) {
+            if (isFirstParam) { 
+                template.append(Constants.PARAMS_START);
+                isFirstParam = false;
+            } else {
+                template.append(Constants.NEXT_PARAM);
+            }
+            template.append(insertPair(Constants.PORTLET_HANDLE));
+        }
+
+        if (needsUserContextKey) {
+            if (isFirstParam) {
+                template.append(Constants.PARAMS_START);
+                isFirstParam = false;
+            } else {
+                template.append(Constants.NEXT_PARAM);
+            }
+            template.append(insertPair(Constants.USER_CONTEXT_KEY));
+        }
+
+        if (needsPortletInstanceKey) {
+            if (isFirstParam) {
+                template.append(Constants.PARAMS_START);
+                isFirstParam = false;
+            } else {
+                template.append(Constants.NEXT_PARAM);
+            }
+            template.append(insertPair(Constants.PORTLET_INSTANCE_KEY));
+        }
+
+        if (needsSessionID) {
+            if (isFirstParam) {
+                template.append(Constants.PARAMS_START);
+                isFirstParam = false;
+            } else {
+                template.append(Constants.NEXT_PARAM);
+            }
+            template.append(insertPair(Constants.SESSION_ID));
+        }
+
+        // append remainder (static parameters)
+        if (remainder != null) {
+            template.append(Constants.NEXT_PARAM);
+            template.append(remainder);
+        }
+
+        return template.toString();
+    }
+
+    /**
+     * creates a pair of an attribute<br/>
+     * 
+     * @param token
+     * @return String with the following format: token={token}
+     */
+    protected String insertPair(String token) {
+        StringBuffer result = new StringBuffer(token);
+        result.append(Constants.EQUALS);
+        result.append(Constants.REPLACE_START);
+        result.append(token);
+        result.append(Constants.REPLACE_END);
+
+        return result.toString();
+    }
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserContextExtension.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserContextExtension.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserContextExtension.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserContextExtension.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,74 @@
+package org.apache.cocoon.portal.wsrp.consumer;
+
+import oasis.names.tc.wsrp.v1.types.UserContext;
+
+/**
+ * Extends the <tt>UserContext</tt>-class with the supportedLocales.
+ * Without these extension the supportedLocales can only be set global for
+ * the consumerEnvironment. In that case all users have the same locale.
+ * Now the supportedLocales can be set per user.<br/>
+ * 
+ * The order of the locales is important. If the first entry is not offered 
+ * by the portlet the second will be tested and so on. The first match delivers
+ * the used locale.<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 UserContextExtension extends UserContext {
+
+    /** The locales for the user. */
+    protected String[] supportedLocales;
+
+    /** User Authentication. */
+    protected String userAuthentication;
+
+    /**
+     * Default constructor
+     */
+    public UserContextExtension() {
+        super();
+    }
+    
+    /**
+     * Constructor
+     * 
+     * @param extensions
+     * @param profile
+     * @param userCategories
+     * @param userContextKey
+     */
+    public UserContextExtension(
+            oasis.names.tc.wsrp.v1.types.Extension[] extensions,
+            oasis.names.tc.wsrp.v1.types.UserProfile profile,
+            java.lang.String[] userCategories,
+            java.lang.String userContextKey) {
+        super(extensions, profile, userCategories, userContextKey);
+    }
+
+    /**
+     * Set the supportedLocales for the current user
+     * 
+     * @param supportedLocales
+     */
+    public void setSupportedLocales(String[] supportedLocales) {
+        this.supportedLocales = supportedLocales;
+    }
+    
+    /**
+     * @return all locales the user wants to support
+     */
+    public String[] getSupportedLocales() {
+        return this.supportedLocales;
+    }
+
+    public String getUserAuthentication() {
+        return userAuthentication;
+    }
+
+    public void setUserAuthentication(String userAuthentication) {
+        this.userAuthentication = userAuthentication;
+    }
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProvider.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProvider.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProvider.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProvider.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,42 @@
+/*
+ * 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;
+
+/**
+ * This component provides the {@link oasis.names.tc.wsrp.v1.types.UserContext}
+ * for a portal user.
+ * Cocoon uses an extension of the user context: {@link UserContextExtension}
+ * to store additional information about the user.
+ * 
+ * @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 interface UserContextProvider {
+
+    /** The component role. */
+    String ROLE = UserContextProvider.class.getName();
+
+    /**
+     * Delivers a <tt>UserContext</tt>-object for the given User-id <br />
+     * the data will be read out of an individual location <br />
+     * 
+     * @param userId
+     * @return UserContextExtension
+     */
+    UserContextExtension createUserContext(String userId);
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProviderImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProviderImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProviderImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProviderImpl.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,96 @@
+/*
+ * 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.thread.ThreadSafe;
+import org.apache.wsrp4j.consumer.util.ConsumerConstants;
+import org.apache.wsrp4j.util.Constants;
+
+import oasis.names.tc.wsrp.v1.types.Contact;
+import oasis.names.tc.wsrp.v1.types.EmployerInfo;
+import oasis.names.tc.wsrp.v1.types.PersonName;
+import oasis.names.tc.wsrp.v1.types.UserProfile;
+
+/**
+ * This is the default implementation just returning an empty
+ * user context.<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 UserContextProviderImpl implements UserContextProvider, ThreadSafe {
+
+    /**
+     * @see org.apache.cocoon.portal.wsrp.consumer.UserContextProvider#createUserContext(java.lang.String)
+     */
+    public UserContextExtension createUserContext(String userId) {
+        final UserContextExtension userContext = new UserContextExtension();
+
+        userContext.setUserContextKey(userId);
+
+        UserProfile userProfile = new UserProfile();
+        this.fill(userProfile, userContext);
+
+        PersonName personName = new PersonName();
+        this.fill(personName, userContext);
+
+        userProfile.setName(personName);
+        userContext.setProfile(userProfile);
+
+        userContext.setUserAuthentication(ConsumerConstants.PASSWORD);
+        this.setSupportedLocales(userContext);
+        return userContext;
+    }
+    
+    /**
+     * Sets the supportedLocales out of an individual location
+     * This method can be overwritten in sub classes.<br/>
+     * 
+     * @param userContext
+     */
+    protected void setSupportedLocales(UserContextExtension userContext) {
+        String[] supportedLocales = new String[2];
+        supportedLocales[0] = Constants.LOCALE_EN_US;
+        supportedLocales[1] = Constants.LOCALE_DE_DE;
+        userContext.setSupportedLocales(supportedLocales);
+    }
+    
+    /**
+     * Fill the user profile.<br/>
+     * This method can be overwritten in sub classes.<br/
+     * 
+     * @param profile
+     * @param context
+     */
+    protected void fill(UserProfile profile, UserContextExtension context) {
+        profile.setEmployerInfo(new EmployerInfo());
+        profile.setHomeInfo(new Contact());
+        profile.setBusinessInfo(new Contact());
+    }
+
+    /**
+     * Fill the name.<br/>
+     * This method can be overwritten in sub classes.<br/>
+     * 
+     * @param name
+     * @param context
+     */
+    protected void fill(PersonName name, UserContextExtension context) {
+        name.setNickname(context.getUserContextKey());
+    }
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserRegistryImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserRegistryImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserRegistryImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserRegistryImpl.java Tue Aug 30 03:29:21 2005
@@ -0,0 +1,37 @@
+/*
+ * 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.wsrp4j.consumer.driver.GenericUserRegistryImpl;
+
+/**
+ * User registry storing all users in a {@link java.util.Hashtable}
+ * in memory. The user registry is filled by the wsrp adapter.
+ *
+ * @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 UserRegistryImpl extends GenericUserRegistryImpl {
+
+    /**
+     * Default constructor
+     */
+    public UserRegistryImpl() {
+        super();
+    }
+}

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

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

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserSessionImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserSessionImpl.java?rev=264755&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserSessionImpl.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/wsrp/consumer/UserSessionImpl.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 java.util.Hashtable;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.wsrp4j.consumer.GroupSessionMgr;
+import org.apache.wsrp4j.consumer.driver.GenericUserSessionImpl;
+import org.apache.wsrp4j.exception.WSRPException;
+
+/**
+ * Implements a simple consumer-based user session<br/>
+ * 
+ * Note: Since most of this methods all only for the session handler,
+ * consider to make most of the methods package scoped.<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 UserSessionImpl extends GenericUserSessionImpl {
+
+    /** The logger */
+    protected final Logger logger;
+
+    /**
+     * Constructor <br/
+     * 
+     * @param producerID
+     * @param userID
+     * @param markupURL
+     * @param logger
+     * @throws WSRPException
+     */
+    public UserSessionImpl(String producerID, 
+                           String userID, 
+                           String markupURL,
+                           Logger logger)
+    throws WSRPException {
+        super(producerID, userID, markupURL);
+        this.logger = logger;
+        this.setGroupSessionTable(new Hashtable());
+    }
+
+    /**
+     * Get the group session for this group ID<br/>
+     *     
+     * @param groupID ID of the portlet application
+     * @return The a group session for the provided group ID or a new groupSession
+     **/
+    public GroupSessionMgr getGroupSession(String groupID) throws WSRPException {
+        GroupSessionMgr groupSession = null;
+        if (groupID != null) {
+            groupSession = (GroupSessionMgr)this.groupSessions.get(groupID);
+            if (groupSession == null) {
+                groupSession = new GroupSessionImpl(groupID, this.getMarkupInterfaceURL(), this.logger);
+                addGroupSession(groupSession);
+            }
+        }
+        return groupSession;
+    }
+}

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

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



Mime
View raw message