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

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLGeneratorImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLGeneratorImpl.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLGeneratorImpl.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLGeneratorImpl.java Tue Aug 30 04:10:28 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/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLGeneratorImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLRewriterImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLRewriterImpl.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLRewriterImpl.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLRewriterImpl.java Tue Aug 30 04:10:28 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/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLRewriterImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLTemplateComposerImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLTemplateComposerImpl.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLTemplateComposerImpl.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLTemplateComposerImpl.java Tue Aug 30 04:10:28 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/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/URLTemplateComposerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextExtension.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextExtension.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextExtension.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextExtension.java Tue Aug 30 04:10:28 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/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextExtension.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProvider.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProvider.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProvider.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProvider.java Tue Aug 30 04:10:28 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/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProviderImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProviderImpl.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProviderImpl.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProviderImpl.java Tue Aug 30 04:10:28 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/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserContextProviderImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserRegistryImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserRegistryImpl.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserRegistryImpl.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserRegistryImpl.java Tue Aug 30 04:10:28 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/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserRegistryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserSessionImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserSessionImpl.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserSessionImpl.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserSessionImpl.java Tue Aug 30 04:10:28 2005
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.wsrp.consumer;
+
+import 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/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/UserSessionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/WSRPRequestImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/WSRPRequestImpl.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/WSRPRequestImpl.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/WSRPRequestImpl.java Tue Aug 30 04:10:28 2005
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2000-2001,2004 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.ClientData;
+import oasis.names.tc.wsrp.v1.types.MarkupContext;
+import oasis.names.tc.wsrp.v1.types.NamedString;
+import oasis.names.tc.wsrp.v1.types.SessionContext;
+
+import org.apache.wsrp4j.consumer.ConsumerEnvironment;
+import org.apache.wsrp4j.consumer.InteractionRequest;
+import org.apache.wsrp4j.consumer.MarkupRequest;
+import org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl;
+
+/**
+ * Holds all parameters to communicate with the producer to get the right portlet.
+ * It uses the {@link org.apache.cocoon.portal.wsrp.consumer#SimplePortletSessionImpl}
+ * to get the window-information, the {@link org.apache.cocoon.portal.wsrp.consumer#Request} 
+ * for the interaction-state, form-parameters and so on, last but not least the 
+ * {@link org.apache.cocoon.portal.wsrp.consumer#consumerEnvironment} for all 
+ * other information.<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 WSRPRequestImpl extends GenericWSRPBaseRequestImpl 
+                             implements InteractionRequest, MarkupRequest {
+
+    /** Portlet-window settings */
+    protected final SimplePortletWindowSession windowSession;
+    
+    /** Request-parameters */
+    protected final Request request;
+    
+    /** Consumer environment contains all registries to get the required information*/
+    protected final ConsumerEnvironment consEnv;
+    
+	/**
+     * Constructor
+     * 
+	 * @param session
+	 * @param request
+	 * @param env ConsumerEnvironment
+	 */
+	public WSRPRequestImpl(SimplePortletWindowSession session,
+                           Request request,
+                           ConsumerEnvironment env) {
+		if (session == null) {
+			throw(new IllegalStateException("session must not be null"));
+		}
+		if (env == null) {
+			throw(new IllegalStateException("environment must not be null"));
+		}
+        if ( request == null ) {
+            this.request = new RequestImpl();
+        } else {
+            this.request = request;
+        }
+		this.windowSession = session;
+		this.consEnv = env;
+	}
+	
+	/**
+	 * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getSessionID()
+	 */
+	public String getSessionID() {
+		SessionContext sessionCtx = windowSession.getPortletSession().getSessionContext();
+		if (sessionCtx != null) {
+			return sessionCtx.getSessionID();
+		}
+		return null;
+	}
+
+	/**
+	 * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getPortletInstanceKey()
+	 */
+	public String getPortletInstanceKey() {
+		return windowSession.getWindowID();
+	}
+
+	/**
+	 * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getNavigationalState()
+	 */
+	public String getNavigationalState() {
+		return windowSession.getNavigationalState();
+	}
+
+	/**
+	 * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getWindowState()
+	 */
+	public String getWindowState() {
+		return windowSession.getWindowState();
+	}
+
+	/**
+	 * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getMode()
+	 */
+	public String getMode()	{
+		return this.windowSession.getMode();
+	}
+
+	/**
+	 * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getClientData()
+	 */
+	public ClientData getClientData() {
+		return null;
+	}
+
+	/**
+	 * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getLocales()
+	 */
+	public String[] getLocales() {
+		return this.consEnv.getSupportedLocales();
+	}
+
+	/**
+	 * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getModes()
+	 */
+	public String[] getModes() {
+		return this.consEnv.getSupportedModes();
+	}
+
+	/**
+	 * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getWindowStates()
+	 */
+	public String[] getWindowStates() {
+		return this.consEnv.getSupportedWindowStates();
+	}
+
+	/**
+	 * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getMimeTypes()
+	 */
+	public String[] getMimeTypes() {
+		return consEnv.getMimeTypes();
+	}
+
+	/**
+	 * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getCharacterEncodingSet()
+	 */
+	public String[] getCharacterEncodingSet() {
+		return this.consEnv.getCharacterEncodingSet();
+	}
+
+	/**
+	 * @see org.apache.wsrp4j.consumer.driver.GenericWSRPBaseRequestImpl#getUserAuthentication()
+	 */
+	public String getUserAuthentication() {
+		return this.consEnv.getUserAuthentication();
+	}
+
+	/**
+	 * @see org.apache.wsrp4j.consumer.InteractionRequest#getInteractionState()
+	 */
+	public String getInteractionState() {
+		return this.request.getInteractionState();
+	}
+
+	/**
+	 * @see org.apache.wsrp4j.consumer.InteractionRequest#getFormParameters()
+	 */
+	public NamedString[] getFormParameters() {
+		return this.request.getFormParameters();
+	}
+
+	/**
+	 * @see org.apache.wsrp4j.consumer.MarkupRequest#getCachedMarkup()
+	 */
+	public MarkupContext getCachedMarkup() {
+		return this.windowSession.getCachedMarkup();
+	}
+}

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

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/logging/WSRPLogManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/logging/WSRPLogManager.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/logging/WSRPLogManager.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/logging/WSRPLogManager.java Tue Aug 30 04:10:28 2005
@@ -0,0 +1,50 @@
+/*
+ * 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.logging;
+
+import org.apache.wsrp4j.log.LogManager;
+import org.apache.wsrp4j.log.Logger;
+
+/**
+ * This log manager implementation just always returns the portal logger.<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 WSRPLogManager extends LogManager {
+
+    /** The logger-object */
+    protected final WSRPLogger logger;
+
+    /**
+     * constructor<br/>
+     * 
+     * @param logger
+     */
+    public WSRPLogManager(WSRPLogger logger) {
+        this.logger = logger;
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.LogManager#getLogger(java.lang.Class)
+     */
+    public Logger getLogger(Class arg0) {
+        return this.logger;
+    }
+
+}

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

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/logging/WSRPLogger.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/logging/WSRPLogger.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/logging/WSRPLogger.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/logging/WSRPLogger.java Tue Aug 30 04:10:28 2005
@@ -0,0 +1,224 @@
+/*
+ * 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.logging;
+
+import org.apache.wsrp4j.log.Logger;
+
+/**
+ * A wrapper for the cocoon logger<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 WSRPLogger implements Logger {
+
+    /** The avalon logger */
+    protected final org.apache.avalon.framework.logger.Logger logger;
+
+    /**
+     * constructor<br/>
+     * 
+     * @param logger
+     */
+    public WSRPLogger(org.apache.avalon.framework.logger.Logger logger) {
+        this.logger = logger;
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#entry(int, java.lang.String)
+     */
+    public void entry(int logLevel, String loggingMethod) {
+        this.entry(logLevel, loggingMethod, null);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#entry(int, java.lang.String, java.lang.Object)
+     */
+    public void entry(int logLevel, String loggingMethod, Object parm1) {
+        this.entry(logLevel, loggingMethod, new Object[] { parm1 });
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#entry(int, java.lang.String, java.lang.Object[])
+     */
+    public void entry(int logLevel, String loggingMethod, Object[] parms) {
+        this.text(logLevel, loggingMethod, "Entering method", parms);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#exit(int, java.lang.String)
+     */
+    public void exit(int logLevel, String loggingMethod) {
+        this.text(logLevel, loggingMethod, "Exiting method.");
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#exit(int, java.lang.String, byte)
+     */
+    public void exit(int logLevel, String loggingMethod, byte retValue) {
+        this.exit(logLevel, loggingMethod, new Byte(retValue));
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#exit(int, java.lang.String, short)
+     */
+    public void exit(int logLevel, String loggingMethod, short retValue) {
+        this.exit(logLevel, loggingMethod, new Short(retValue));
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#exit(int, java.lang.String, int)
+     */
+    public void exit(int logLevel, String loggingMethod, int retValue) {
+        this.exit(logLevel, loggingMethod, new Integer(retValue));
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#exit(int, java.lang.String, long)
+     */
+    public void exit(int logLevel, String loggingMethod, long retValue) {
+        this.exit(logLevel, loggingMethod, new Long(retValue));
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#exit(int, java.lang.String, float)
+     */
+    public void exit(int logLevel, String loggingMethod, float retValue) {
+        this.exit(logLevel, loggingMethod, new Float(retValue));
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#exit(int, java.lang.String, double)
+     */
+    public void exit(int logLevel, String loggingMethod, double retValue) {
+        this.exit(logLevel, loggingMethod, new Double(retValue));
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#exit(int, java.lang.String, char)
+     */
+    public void exit(int logLevel, String loggingMethod, char retValue) {
+        this.exit(logLevel, loggingMethod, new Character(retValue));
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#exit(int, java.lang.String, boolean)
+     */
+    public void exit(int logLevel, String loggingMethod, boolean retValue) {
+        this.exit(logLevel, loggingMethod, new Boolean(retValue));
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#exit(int, java.lang.String, java.lang.Object)
+     */
+    public void exit(int logLevel, String loggingMethod, Object retValue) {
+        this.text(logLevel, loggingMethod, "Exiting method. Returned value: {0}", retValue);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#isLogging(int)
+     */
+    public boolean isLogging(int logLevel) {
+        if (logLevel == Logger.ERROR ) {
+            return this.logger.isErrorEnabled();
+        } else if ( logLevel == Logger.INFO ) {            
+            return this.logger.isInfoEnabled();
+        } else if ( logLevel == Logger.WARN ) {            
+            return this.logger.isWarnEnabled();
+        } else if ( logLevel == Logger.TRACE_HIGH ) {            
+            return this.logger.isInfoEnabled();
+        } else if ( logLevel == Logger.TRACE_MEDIUM ) {            
+            return this.logger.isDebugEnabled();
+        } else if ( logLevel == Logger.TRACE_LOW ) {            
+            return this.logger.isDebugEnabled();
+        }
+        return false;
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#stackTrace(int, java.lang.String, java.lang.String)
+     */
+    public void stackTrace(int logLevel, String loggingMethod, String text) {
+        this.text(logLevel, loggingMethod, new Throwable("Stacktrace"), text);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#text(int, java.lang.String, java.lang.String)
+     */
+    public void text(int logLevel, String loggingMethod, String text) {
+        this.text(logLevel, loggingMethod, text, null);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#text(int, java.lang.String, java.lang.String, java.lang.Object)
+     */
+    public void text(int logLevel, String loggingMethod, String text, Object parm1) {
+        this.text(logLevel, loggingMethod, text, new Object[] { parm1 });
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#text(int, java.lang.String, java.lang.String, java.lang.Object[])
+     */
+    public void text(int logLevel, String loggingMethod, String text, Object[] parms) {
+        this.text(logLevel, loggingMethod, (Throwable) null, text, parms);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#text(int, java.lang.String, java.lang.Throwable, java.lang.String)
+     */
+    public void text(int logLevel, String loggingMethod, Throwable t, String text) {
+        this.text(logLevel, loggingMethod, t, text, null);
+    }
+
+    /**
+     * @see org.apache.wsrp4j.log.Logger#text(int, java.lang.String, java.lang.Throwable, java.lang.String, java.lang.Object[])
+     */
+    public void text(int logLevel, String loggingMethod, Throwable t, String text, Object[] parms) {
+        if (!this.isLogging(logLevel)) {
+            return;
+        }
+        StringBuffer msgBuffer = new StringBuffer();
+        if (loggingMethod != null) {
+            msgBuffer.append(loggingMethod);
+            msgBuffer.append(" - ");
+        }
+        if (text != null) {
+            msgBuffer.append(text);
+        }
+        if (parms != null) {
+            msgBuffer.append("\nParameters:\n");
+            for (int i = 0; i < parms.length; i++) {
+                msgBuffer.append(parms[i]);
+            }
+        }
+
+        if (logLevel == Logger.ERROR ) {
+            this.logger.error(msgBuffer.toString(), t);
+        } else if ( logLevel == Logger.INFO ) {            
+            this.logger.info(msgBuffer.toString(), t);
+        } else if ( logLevel == Logger.WARN ) {            
+            this.logger.warn(msgBuffer.toString(), t);
+        } else if ( logLevel == Logger.TRACE_HIGH ) {            
+            this.logger.info(msgBuffer.toString(), t);
+        } else if ( logLevel == Logger.TRACE_MEDIUM ) {            
+            this.logger.debug(msgBuffer.toString(), t);
+        } else if ( logLevel == Logger.TRACE_LOW ) {            
+            this.logger.debug(msgBuffer.toString(), t);
+        }
+    }
+}

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

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

Modified: cocoon/blocks/portal/trunk/samples/coplets/docs/portal-demo.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/samples/coplets/docs/portal-demo.xml?rev=264757&r1=264756&r2=264757&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/samples/coplets/docs/portal-demo.xml (original)
+++ cocoon/blocks/portal/trunk/samples/coplets/docs/portal-demo.xml Tue Aug 30 04:10:28 2005
@@ -33,6 +33,7 @@
           <li>The TabDemo2 shows the same content as TabDemo2 but with just a different stylesheet for the tab.</li>
           <li>The Gallery tab shows some more coplets.</li>
           <li>The JSR-168 tab demonstrates the integration of Portlets (read more below).</li>
+          <li>The WSRP tab demonstrates the integration of WSRP portlets (read more below).</li>
         </ul>
         <p><strong>THIS IS A SAMPLE PORTAL!</strong></p>
         <p>It demonstrates several features of 
@@ -58,6 +59,15 @@
         <p>The current implementation searches for portlets in all directories that are next to
          the Cocoon webapp directory. So, if you put Cocoon into the webapps directory of Tomcat,
          you should put your portlets there as well.</p>
+     </s1>
+     <s1 title="WSRP">
+        <p>The Cocoon portal supports portlets conforming to the WSRP. The WSRP tab contains 
+           a sample using the testsuite from the <fork href="http://ws.apache.org/wsrp4j">WSRP4J project</fork>.</p>
+        <p>These samples only work if you follow these installation instructions:</p>
+        <ul>
+         <li>Get the WSRP4J project and install it into Tomcat (Test WSRP using the SwingConsumer now).</li>
+         <li>Start up Tomcat (with the WSRP producer) and Cocoon (using Jetty) and run the Cocoon portal demo. You should see the WSRP portlets now.</li>
+        </ul>
      </s1>
   </body>
 </document>

Modified: cocoon/blocks/portal/trunk/samples/profiles/copletbasedata/portal.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/samples/profiles/copletbasedata/portal.xml?rev=264757&r1=264756&r2=264757&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/samples/profiles/copletbasedata/portal.xml (original)
+++ cocoon/blocks/portal/trunk/samples/profiles/copletbasedata/portal.xml Tue Aug 30 04:10:28 2005
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-  Copyright 1999-2004 The Apache Software Foundation
+  Copyright 1999-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.
@@ -14,8 +14,8 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<!-- SVN $Id:$ -->
-<coplets>
+<!-- SVN $Id$ -->
+<coplets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <coplet-base-data id="URICoplet">
       <coplet-adapter>uri</coplet-adapter>
    </coplet-base-data>
@@ -27,6 +27,13 @@
    </coplet-base-data>
    <coplet-base-data id="Application">
       <coplet-adapter>application</coplet-adapter>
+   </coplet-base-data>
+   <coplet-base-data id="WSRP">
+      <coplet-adapter>wsrp</coplet-adapter>
+      <configuration>
+      	<name>buffer</name>
+      	<value xsi:type="java:java.lang.Boolean">true</value>
+      </configuration>
    </coplet-base-data>
 </coplets>