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 [2/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...

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

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

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

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

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverRegistryImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverRegistryImpl.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverRegistryImpl.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletDriverRegistryImpl.java Tue Aug 30 04:10:28 2005
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.wsrp.consumer;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter;
+import org.apache.wsrp4j.consumer.ConsumerEnvironment;
+import org.apache.wsrp4j.consumer.PortletDriver;
+import org.apache.wsrp4j.consumer.PortletDriverRegistry;
+import org.apache.wsrp4j.consumer.WSRPPortlet;
+import org.apache.wsrp4j.exception.WSRPException;
+
+/**
+ * Manages the drivers for the portlets the consumerEnvironment holds<br/>
+ * Per portlet one portletDriver will be stored<br/>
+ *
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * @author <a href="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
+ * 
+ * @version $Id$
+ */
+public class PortletDriverRegistryImpl
+    implements PortletDriverRegistry,
+               RequiresConsumerEnvironment,
+               RequiresWSRPAdapter {
+
+    /** All portletDrivers the consumerEnvironment needs. */
+    protected final Hashtable portletDrivers = new Hashtable();
+    
+    /** The consumer environment. */
+    protected ConsumerEnvironment consumerEnv;
+
+    /** The WSRP adapter. */
+    protected WSRPAdapter adapter;
+
+    /**
+     * @see org.apache.cocoon.portal.wsrp.consumer.RequiresConsumerEnvironment#setConsumerEnvironment(org.apache.wsrp4j.consumer.ConsumerEnvironment)
+     */
+    public void setConsumerEnvironment(ConsumerEnvironment env) {
+        this.consumerEnv = env;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.wsrp.consumer.RequiresWSRPAdapter#setWSRPAdapter(org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter)
+     */
+    public void setWSRPAdapter(WSRPAdapter adapter) {
+        this.adapter = adapter;
+    }
+
+    /**
+     * Get an portlet driver for the given portlet. If there is no portlet driver
+     * object cached a new portlet driver will be created and returned.
+     * 
+     * @param portlet The portlet the returned portlet driver is bound to.
+     * 
+     * @return The portlet driver for this portlet.
+     **/
+    public PortletDriver getPortletDriver(WSRPPortlet portlet)
+    throws WSRPException {
+        PortletDriver driver = null;
+
+        if ((driver = (PortletDriver)portletDrivers.get(portlet.getPortletKey().toString())) == null) {
+            String driverClass = this.adapter.getAdapterConfiguration().getParameter("portlet-driver-class", PortletDriverImpl.class.getName());
+            try {
+                driver = (PortletDriverImpl)this.adapter.createObject(driverClass);
+            } catch (Exception e) {
+                throw new WSRPException(0, e);
+            }
+            ((PortletDriverImpl)driver).init(portlet);
+            this.portletDrivers.put(portlet.getPortletKey().toString(), driver);
+        }
+        return driver;
+    }
+
+    /**
+     * Get all cached portlet drivers.
+     * 
+     * @return Iterator with all portlet drivers in the registry.
+     **/
+    public Iterator getAllPortletDrivers() {
+        return portletDrivers.values().iterator();
+    }
+}

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

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletRegistryImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletRegistryImpl.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletRegistryImpl.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletRegistryImpl.java Tue Aug 30 04:10:28 2005
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.wsrp.consumer;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.wsrp4j.consumer.PortletKey;
+import org.apache.wsrp4j.consumer.WSRPPortlet;
+import org.apache.wsrp4j.consumer.driver.ConsumerPortletContext;
+import org.apache.wsrp4j.consumer.driver.GenericPortletRegistryImpl;
+import org.apache.wsrp4j.exception.WSRPException;
+import org.apache.wsrp4j.util.StateChangedEvent;
+import org.apache.wsrp4j.util.StateChangedListener;
+import org.apache.wsrp4j.util.StateChangedService;
+
+/**
+ * This class is the <code>PortletRegistry</code> implementation used
+ * to administer, store, load and manage portlets.<br/>
+ *  
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * @author <a href="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
+ *
+ * @version $Id$
+ **/
+public class PortletRegistryImpl
+    extends GenericPortletRegistryImpl
+    implements StateChangedListener, LogEnabled {
+
+    /** The logger. */
+    protected Logger logger;
+
+    /** maps portlet keys to portlet context. */
+    private Hashtable contextMap = new Hashtable();
+
+    /**
+     * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
+     */
+    public void enableLogging(Logger logger) {
+        this.logger = logger;
+    }
+
+    /**
+     * Add a portlet to the registry<br/>
+     *
+     * @param portlet The portlet to add
+     * @throws WSRPException on error
+     */
+    public void addPortlet(WSRPPortlet portlet) throws WSRPException {
+        if (portlet != null) {
+            super.addPortlet(portlet);
+
+            // store PortletContext to persistent file
+            ConsumerPortletContext consumerPortletContext = new ConsumerPortletContext();
+            consumerPortletContext.setPortletContext(portlet.getPortletContext());
+            consumerPortletContext.setPortletKey(portlet.getPortletKey());
+            this.contextMap.put(portlet.getPortletKey().toString(), consumerPortletContext);
+
+            // add as listener
+            if (portlet instanceof StateChangedService) {
+                ((StateChangedService)portlet).addListener(this);
+            }
+        }
+    }
+
+    /**
+     * Remove the portlet with the given portlet key<br/>
+     *
+     * @param portletKey The portlet key identifying the portlet
+     * @return returns the removed instance of WSRPPortlet
+     **/
+    public WSRPPortlet removePortlet(PortletKey portletKey) {
+        WSRPPortlet portlet = null;
+        if (portletKey != null) {
+            portlet = super.removePortlet(portletKey);
+            contextMap.remove(portletKey.toString());
+        }
+        return portlet;
+    }
+
+    /**
+     * Remove all portlets from the registry and delete them in the
+     * persistent store.
+     **/
+    public void removeAllPortlets() {
+        Iterator iterator = getAllPortlets();
+        while (iterator.hasNext()) {
+            WSRPPortlet portlet = (WSRPPortlet)iterator.next();
+
+            // remove ConsumerPortletContext from map
+            contextMap.remove(portlet.getPortletKey().toString());
+        }
+        super.removeAllPortlets();
+    }
+
+    /**
+     * StateChanged Event occured by a registered WSRPPortlet. The
+     * input source object, contained in the event will be
+     * updated in the persistence store.
+     * 
+     * @param event 
+     * @see StateChangedEvent
+     */
+    public void stateChanged(StateChangedEvent event) {
+        WSRPPortlet portlet = null;
+        try {
+            portlet = (WSRPPortlet)event.getSource();
+
+            //store PortletContext to persistent file
+            ConsumerPortletContext consumerPortletContext =
+                (ConsumerPortletContext)contextMap.get(portlet.getPortletKey().toString());
+
+            consumerPortletContext.setPortletContext(portlet.getPortletContext());
+            consumerPortletContext.setPortletKey(portlet.getPortletKey());
+        } catch (ClassCastException ce) {
+            logger.error("StateChanged-error in portlet: " + portlet.getPortletKey().getPortletHandle(), ce);
+        }
+    }
+}

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

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletSessionImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletSessionImpl.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletSessionImpl.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/PortletSessionImpl.java Tue Aug 30 04:10:28 2005
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.wsrp.consumer;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.wsrp4j.consumer.PortletWindowSession;
+import org.apache.wsrp4j.consumer.driver.GenericPortletSessionImpl;
+import org.apache.wsrp4j.util.Modes;
+import org.apache.wsrp4j.util.WindowStates;
+
+/**
+ * Defines a session object at the consumer-side
+ * to store remote portlet related information that
+ * are needed to interact with the portlet<br/> 
+ * 
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * @author <a href="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
+ *
+ * @version $Id$
+ */
+public class PortletSessionImpl extends GenericPortletSessionImpl {
+
+    /** The logger. */
+    protected final Logger logger;
+
+    /**
+     * constructor
+     * 
+     * @param handle
+     * @param logger
+     */
+    public PortletSessionImpl(String handle, Logger logger) {
+    	super(handle);
+        this.logger = logger;
+    }
+
+    /**
+     * Get the <code>PortletWindowSession</code> of the portlet window with the given ID<br/>
+     * 
+     * @param windowID The ID of the portlet window
+     * @return The <code>PorletWindowSession</code> with the given ID.    
+     **/
+    public PortletWindowSession getPortletWindowSession(String windowID) {
+        SimplePortletWindowSession session = (SimplePortletWindowSession)this.windowSessions.get(windowID);
+        if (session == null) {
+            session = new SimplePortletWindowSessionImpl(windowID, this);
+            session.setMode(Modes._view);
+            session.setWindowState(WindowStates._normal);
+            this.windowSessions.put(windowID, session);
+
+            if ( this.logger.isDebugEnabled() ) {
+            	logger.debug("Created windowSession with ID: " + windowID);
+            }
+        }
+        return session;
+    }
+}

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

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

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/ProducerDescription.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/ProducerDescription.java?rev=264757&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/ProducerDescription.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/wsrp/consumer/ProducerDescription.java Tue Aug 30 04:10:28 2005
@@ -0,0 +1,282 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.wsrp.consumer;
+
+import oasis.names.tc.wsrp.v1.types.RegistrationData;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter;
+import org.apache.wsrp4j.consumer.ConsumerEnvironment;
+
+/**
+ * Describes and creates producers.<br/>
+ * If the registration interface url is set (not null) this implies
+ * that the producer requires a registration. If the producer does
+ * not require a registration, set the registration interface url
+ * to null<br/>
+ *
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * @author <a href="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
+ *
+ * @version $Id$
+ **/
+public class ProducerDescription {
+
+    /** Unique string of the producer */
+    protected String id;
+
+    /** The wsrp makup-interface-url (required) */
+    protected String markupInterfaceUrl;
+
+    /** The wsrp service-description-interface-url (required) */
+    protected String serviceDescriptionInterfaceUrl;
+
+    /** The wsrp registration-interface-url (optional) */
+    protected String registrationInterfaceUrl;
+
+    /** The wsrp portlet-management-interface-url (optional) */
+    protected String portletManagementInterfaceUrl;
+    
+    /** name of the producer */
+    protected String name;
+    
+    /** description of the producer */
+    protected String description;
+
+    /** The registration data. */
+    protected RegistrationData registrationData;
+
+    /**
+     * Default constructor
+     */
+    public ProducerDescription() {
+        this(null);
+    }
+
+    /**
+     * Constructor<br/>
+     * 
+     * @param id of the producer
+     */
+    public ProducerDescription(String id) {
+        this(id, null, null);
+    }
+
+    /**
+     * Constructor<br/>
+     * 
+     * @param id of the producer
+     * @param markupUrl markup-interface-url
+     * @param sdUrl service-description-interface-url
+     */
+    public ProducerDescription(String id, String markupUrl, String sdUrl) {
+        this(id, markupUrl, sdUrl, null, null);
+    }
+
+    /**
+     * Constructor<br/>
+     * 
+     * @param id of the producer
+     * @param markupUrl markup-interface-url
+     * @param sdUrl service-description-interface-url
+     * @param regUrl registration-interface-url
+     * @param pmUrl portlet-management-interface-url
+     */
+    public ProducerDescription(String id, 
+                               String markupUrl, 
+                               String sdUrl,
+                               String regUrl,
+                               String pmUrl) {
+        this.id = id;
+        this.markupInterfaceUrl = markupUrl;
+        this.serviceDescriptionInterfaceUrl = sdUrl;
+        this.registrationInterfaceUrl = regUrl;
+        this.portletManagementInterfaceUrl = pmUrl;
+    }
+
+    /**
+     * @return producer-id
+     */
+    public String getId() {
+        return id;
+    }
+
+    /**
+     * set the producer-id<br/>
+     * 
+     * @param id
+     */
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    /**
+     * @return markup-interface-url
+     */
+    public String getMarkupInterfaceUrl() {
+        return markupInterfaceUrl;
+    }
+
+    /**
+     * set the markup-interface-url<br/>
+     * 
+     * @param markupInterfaceUrl
+     */
+    public void setMarkupInterfaceUrl(String markupInterfaceUrl) {
+        this.markupInterfaceUrl = markupInterfaceUrl;
+    }
+
+    /**
+     * @return portlet-management-interface-url
+     */
+    public String getPortletManagementInterfaceUrl() {
+        return portletManagementInterfaceUrl;
+    }
+
+    /**
+     * Set the portlet-management-interface-url<br/>
+     * 
+     * @param portletManagementInterfaceUrl
+     */
+    public void setPortletManagementInterfaceUrl(String portletManagementInterfaceUrl) {
+        this.portletManagementInterfaceUrl = portletManagementInterfaceUrl;
+    }
+
+    /**
+     * @return registration-interface-url
+     */
+    public String getRegistrationInterfaceUrl() {
+        return registrationInterfaceUrl;
+    }
+
+    /**
+     * Set the registration-interface-url<br/>
+     * 
+     * @param registrationInterfaceUrl
+     */
+    public void setRegistrationInterfaceUrl(String registrationInterfaceUrl) {
+        this.registrationInterfaceUrl = registrationInterfaceUrl;
+    }
+
+    /**
+     * @return service-description-interface-url
+     */
+    public String getServiceDescriptionInterfaceUrl() {
+        return serviceDescriptionInterfaceUrl;
+    }
+
+    /**
+     * Set the service-description-interface-url<br/>
+     * 
+     * @param serviceDescriptionInterfaceUrl
+     */
+    public void setServiceDescriptionInterfaceUrl(String serviceDescriptionInterfaceUrl) {
+        this.serviceDescriptionInterfaceUrl = serviceDescriptionInterfaceUrl;
+    }
+
+    /**
+     * Create a producer description from a configuration<br/>
+     * 
+     * @param config
+     * @return the producer-description
+     * @throws ConfigurationException
+     */
+    public static ProducerDescription fromConfiguration(Configuration config, ConsumerEnvironment env)
+    throws ConfigurationException {
+        final String producerId = config.getAttribute("id");
+        final ProducerDescription desc = new ProducerDescription(producerId);
+
+        desc.setMarkupInterfaceUrl(config.getChild("markup-interface-url").getValue());
+        desc.setServiceDescriptionInterfaceUrl(config.getChild("service-description-interface-url").getValue());
+        desc.setRegistrationInterfaceUrl(config.getChild("registration-interface-url").getValue(null));
+        desc.setPortletManagementInterfaceUrl(config.getChild("portlet-management-interface-url").getValue(null));
+        boolean registrationRequired;
+        if ( desc.getRegistrationInterfaceUrl() != null ) {
+            registrationRequired = config.getChild("registration-interface-url").getAttributeAsBoolean("registration-required", true);
+        } else {
+            registrationRequired = false;
+        }
+        if ( registrationRequired == false ) {
+            desc.setRegistrationInterfaceUrl(null);
+        } else {
+            // get the registration data
+            desc.setRegistrationData(createRegistrationData(config.getChild("registration-data"), env));
+        }
+
+        // optional information
+        desc.setName(config.getChild("name").getValue(null));
+        desc.setDescription(config.getChild("description").getValue(null));
+
+        return desc;
+    }
+
+    public static RegistrationData createRegistrationData(Configuration config,
+                                                          ConsumerEnvironment env) {
+        RegistrationData registrationData = new RegistrationData(
+                env.getConsumerAgent(),
+                env.getSupportedModes(),
+                WSRPAdapter.CONSUMER_URL,  //consumer-name
+                null,         //consumerUserScopes
+                env.getSupportedWindowStates(),
+                null,         //customUserProfileData
+                null,         //extensions
+                false,        //methodGetSupported 
+                null          //registrationProperties
+                );
+        return registrationData;        
+    }
+
+    /**
+     * @return the producer-description as string
+     */
+    public String getDescription() {
+        return description;
+    }
+
+    /**
+     * Set the producer-description<br/>
+     * 
+     * @param description
+     */
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    /**
+     * @return name of the producer
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Set the producer-name<br/>
+     * 
+     * @param name
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public RegistrationData getRegistrationData() {
+        return registrationData;
+    }
+
+    public void setRegistrationData(RegistrationData registrationData) {
+        this.registrationData = registrationData;
+    }
+}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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