portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlest...@apache.org
Subject svn commit: r209328 [6/14] - in /portals/jetspeed-2/trunk/components/portal: src/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/jetspeed/ src/java/org/apache/jetspeed/aggregator/ src/java/org/apache/jetspeed/aggregator/impl/ src/java...
Date Tue, 05 Jul 2005 21:55:50 GMT
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/NamespaceEncodedSession.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/NamespaceEncodedSession.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/NamespaceEncodedSession.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/NamespaceEncodedSession.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2000-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.jetspeed.engine.servlet;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+
+import javax.servlet.http.HttpSession;
+
+import org.apache.jetspeed.Jetspeed;
+import org.apache.jetspeed.container.namespace.JetspeedNamespaceMapper;
+import org.apache.jetspeed.container.namespace.JetspeedNamespaceMapperFactory;
+import org.apache.pluto.om.common.ObjectID;
+
+/**
+ * @author Scott T Weaver
+ *  
+ */
+public class NamespaceEncodedSession extends HttpSessionWrapper
+{
+
+    private JetspeedNamespaceMapper nameSpaceMapper;
+
+    private ObjectID webAppId;
+
+    private HashSet mappedNames = new HashSet();
+
+    /**
+     * @param session
+     */
+    public NamespaceEncodedSession(HttpSession session, ObjectID webAppId)
+    {
+        super(session);
+        this.nameSpaceMapper = ((JetspeedNamespaceMapperFactory) Jetspeed.getComponentManager().getComponent(
+                org.apache.pluto.util.NamespaceMapper.class)).getJetspeedNamespaceMapper();
+        this.webAppId = webAppId;
+    }
+
+    /**
+     * <p>
+     * setAttribute
+     * </p>
+     * 
+     * @see javax.servlet.ServletRequest#setAttribute(java.lang.String,
+     *      java.lang.Object)
+     * @param arg0
+     * @param arg1
+     */
+    public void setAttribute(String name, Object value)
+    {
+
+        if (name == null)
+        {
+            throw new IllegalArgumentException("Attribute name == null");
+        }
+
+        if (skipEncode(name))
+        {
+            super.setAttribute(name, value);
+        }
+        else
+        {
+            String encodedKey = nameSpaceMapper.encode(webAppId, name);
+            mappedNames.add(name);
+            super.setAttribute(encodedKey, value);
+        }
+
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getAttribute(java.lang.String)
+     */
+    public Object getAttribute(String name)
+    {
+        if (skipEncode(name))
+        {
+            return super.getAttribute(name);
+        }
+        else
+        {
+            return super.getAttribute(nameSpaceMapper.encode(webAppId, name));
+        }
+    }
+
+    private boolean skipEncode(String name)
+    {
+        return name.startsWith(nameSpaceMapper.getPrefix()) || name.startsWith("javax.portlet") || name.startsWith("javax.servlet") || name.startsWith("org.apache.jetspeed");
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.servlet.http.HttpSession#getAttributeNames()
+     */
+    public Enumeration getAttributeNames()
+    {
+        Enumeration names = super.getAttributeNames();
+        while (names.hasMoreElements())
+        {
+            String name = (String) names.nextElement();
+            if (skipEncode(name))
+            {
+                mappedNames.add(name);
+            }
+        }
+
+        return Collections.enumeration(mappedNames);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.servlet.http.HttpSession#removeAttribute(java.lang.String)
+     */
+    public void removeAttribute(String name)
+    {
+        if (skipEncode(name))
+        {
+            super.removeAttribute(name);
+        }
+        else
+        {
+            mappedNames.add(name);
+            super.removeAttribute(nameSpaceMapper.encode(webAppId, name));
+        }
+    }
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletHelper.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletHelper.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletHelper.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletHelper.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2000-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.jetspeed.engine.servlet;
+
+import java.io.File;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * Servlet Helper functions
+ *
+ * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
+ * @version $Id: ServletHelper.java 185962 2004-03-08 01:03:33Z jford $
+ */
+public class ServletHelper
+{
+    public static final String CONFIG_NAMESPACE = "org.apache.jetspeed";
+
+    /** Default Value for the Logging Directory, relative to the webroot */
+    public static final String LOGGING_ROOT_DEFAULT = "/logs";
+    public static final String LOGGING_ROOT = "loggingRoot";
+
+    /**
+     * Used to get the real path of configuration and resource
+     * information. 
+     *
+     * @param path path translated to the application root
+     * @return the real path
+     */
+    public static String getRealPath(ServletConfig config, String path)
+    {
+        if (path.startsWith("/"))
+        {
+            path = path.substring(1);
+        }
+
+        return new File(config.getServletContext().getRealPath(""), path).getAbsolutePath();
+    }
+
+    /**
+     * Finds the specified servlet configuration/initialization
+     * parameter, looking first for a servlet-specific parameter, then
+     * for a global parameter, and using the provided default if not
+     * found.
+     */
+    public static final String findInitParameter(ServletContext context,
+                                                    ServletConfig config,
+                                                    String name,
+                                                    String defaultValue)
+    {
+        String path = null;
+
+        // Try the name as provided first.
+        boolean usingNamespace = name.startsWith(CONFIG_NAMESPACE);
+        while (true)
+        {
+            path = config.getInitParameter(name);
+            if (StringUtils.isEmpty(path))
+            {
+                path = context.getInitParameter(name);
+                if (StringUtils.isEmpty(path))
+                {
+                    // The named parameter didn't yield a value.
+                    if (usingNamespace)
+                    {
+                        path = defaultValue;
+                    }
+                    else
+                    {
+                        // Try again using Jetspeed's namespace.
+                        name = CONFIG_NAMESPACE + '.' + name;
+                        usingNamespace = true;
+                        continue;
+                    }
+                }
+            }
+            break;
+        }
+
+        return path;
+    }
+
+    /**
+     * Create any directories that might be needed during
+     *
+     */
+    public static void createRuntimeDirectories(ServletContext context,
+                                                 ServletConfig config)
+        throws ServletException
+    {
+        String path = findInitParameter(context, config, LOGGING_ROOT, LOGGING_ROOT_DEFAULT);
+        File logDir = new File(getRealPath(config, path));
+        if (!logDir.exists())
+        {
+            // Create the logging directory
+            if (!logDir.mkdirs())
+            {
+                throw new ServletException("Cannot create directory for logs!");
+            }
+        }
+    }
+ }
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletObjectAccess.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletObjectAccess.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletObjectAccess.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletObjectAccess.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2000-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.jetspeed.engine.servlet;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+import org.apache.pluto.core.CoreUtils;
+import org.apache.pluto.core.InternalPortletRequest;
+import org.apache.pluto.core.InternalPortletResponse;
+import org.apache.pluto.om.window.PortletWindow;
+import org.apache.pluto.services.factory.FactoryManager;
+
+/**
+ * Provides access to servlet request and response wrappers
+ * 
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: ServletObjectAccess.java 185962 2004-03-08 01:03:33Z jford $
+ */
+public abstract class ServletObjectAccess
+{
+    public static HttpServletRequest getServletRequest(HttpServletRequest request, PortletWindow window)
+    {
+    	System.out.println("n");
+        return requestFactory.getServletRequest(request, window);
+    }
+
+    public static HttpServletResponse getServletResponse(HttpServletResponse response, PortletWindow window)
+    {
+        return responseFactory.getServletResponse(response);
+    }
+
+    public static HttpServletRequest getServletRequest(PortletRequest request)
+    {
+        InternalPortletRequest internalPortletRequest = CoreUtils.getInternalRequest(request);
+
+        return  (HttpServletRequest) ((javax.servlet.http.HttpServletRequestWrapper) internalPortletRequest).getRequest();
+            
+    }
+
+    public static HttpServletResponse getServletResponse(PortletResponse response)
+    {
+        InternalPortletResponse internalPortletResponse = CoreUtils.getInternalResponse(response);
+        return (HttpServletResponse) ((HttpServletResponseWrapper) internalPortletResponse).getResponse();
+            
+    }
+
+    private static ServletRequestFactory requestFactory =
+        (ServletRequestFactory) FactoryManager.getFactory(javax.servlet.http.HttpServletRequest.class);
+    private static ServletResponseFactory responseFactory =
+        (ServletResponseFactory) FactoryManager.getFactory(javax.servlet.http.HttpServletResponse.class);
+
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestFactory.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestFactory.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestFactory.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestFactory.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2000-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.jetspeed.engine.servlet;
+
+import javax.servlet.http.HttpServletRequest;
+import org.apache.pluto.factory.Factory;
+import org.apache.pluto.om.window.PortletWindow;
+
+/**
+ * Factory interface for creating HTTP Request Wrappers
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: ServletRequestFactory.java 185962 2004-03-08 01:03:33Z jford $
+ */
+public interface ServletRequestFactory extends Factory
+{
+    public HttpServletRequest getServletRequest(HttpServletRequest request, PortletWindow window);
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestFactoryImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestFactoryImpl.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestFactoryImpl.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestFactoryImpl.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2000-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.jetspeed.engine.servlet;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Map;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.pluto.om.window.PortletWindow;
+
+/**
+ * Factory implementation for creating HTTP Request Wrappers
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: ServletRequestFactoryImpl.java 188183 2005-01-12 09:20:47Z ate $
+ */
+public class ServletRequestFactoryImpl
+    implements ServletRequestFactory
+{
+    private ServletConfig servletConfig;
+    
+    public void init(javax.servlet.ServletConfig config, Map properties) 
+    throws Exception
+    {
+        servletConfig = config;
+    }
+    
+    public void destroy()
+    throws Exception
+    {
+    }
+
+    protected HttpServletRequest createRequest(HttpServletRequest request, PortletWindow window)
+    {
+        return new ServletRequestImpl(request, window);        
+    }
+    
+    public HttpServletRequest getServletRequest(HttpServletRequest request, PortletWindow window)
+    {
+        HttpServletRequest servletRequest = createRequest(request, window);
+        
+        // Set page encoding in order to parse the form data correctly        
+        String preferedEnc = (String) request.getAttribute(PortalReservedParameters.PREFERED_CHARACTERENCODING_ATTRIBUTE);
+        if (preferedEnc != null)
+        {
+            try
+            {
+                servletRequest.setCharacterEncoding(preferedEnc);
+            }
+            catch (UnsupportedEncodingException e)
+            {
+                ;
+            }
+        }
+
+        return servletRequest;
+    }
+    
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,464 @@
+/*
+ * Copyright 2000-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.jetspeed.engine.servlet;
+
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.portlet.PortletRequest;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.Jetspeed;
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.container.namespace.JetspeedNamespaceMapper;
+import org.apache.jetspeed.container.namespace.JetspeedNamespaceMapperFactory;
+import org.apache.jetspeed.container.url.PortalURL;
+import org.apache.jetspeed.request.JetspeedRequestContext;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.pluto.om.common.ObjectID;
+import org.apache.pluto.om.entity.PortletApplicationEntity;
+import org.apache.pluto.om.entity.PortletEntity;
+import org.apache.pluto.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.om.portlet.PortletDefinition;
+import org.apache.pluto.om.window.PortletWindow;
+import org.apache.pluto.util.Enumerator;
+
+/**
+ * This request wrappers the servlet request and is used within the container to
+ * communicate to the invoked servlet.
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: ServletRequestImpl.java 188577 2005-05-17 15:57:13Z ate $
+ */
+public class ServletRequestImpl extends HttpServletRequestWrapper
+{
+    public static final String ACCEPT_LANGUAGE = "Accept-Language";
+    /** Logger */
+    private static final Log log = LogFactory.getLog(ServletRequestImpl.class);
+
+    PortletWindow portletWindow = null;
+    private JetspeedNamespaceMapper nameSpaceMapper = null;
+    private ServletRequest currentRequest = null;
+
+    private Map portletParameters;
+    private ObjectID webAppId;
+
+    public ServletRequestImpl( HttpServletRequest servletRequest, PortletWindow window )
+    {
+        super(servletRequest);
+        nameSpaceMapper = ((JetspeedNamespaceMapperFactory) Jetspeed.getComponentManager().getComponent(
+                org.apache.pluto.util.NamespaceMapper.class)).getJetspeedNamespaceMapper();
+        this.portletWindow = window;        
+        PortletDefinition portletDef = portletWindow.getPortletEntity().getPortletDefinition();
+        if(portletDef != null)
+        {
+            webAppId = portletDef.getPortletApplicationDefinition().getWebApplicationDefinition().getId();
+        }
+        else
+        {
+            // This happens when an entity is referencing a non-existent portlet
+            webAppId = window.getId();
+        }
+    }
+
+    protected HttpServletRequest _getHttpServletRequest()
+    {
+        return (HttpServletRequest) super.getRequest();
+    }
+
+    //  ServletRequestWrapper overlay
+
+    public String getParameter( String name )
+    {
+        Object value = this.getParameterMap().get(name);
+        if (value == null)
+        {
+            return (null);
+        }
+        else if (value instanceof String[])
+        {
+            return (((String[]) value)[0]);
+        }
+        else if (value instanceof String)
+        {
+            return ((String) value);
+        }
+        else
+        {
+            return (value.toString());
+        }
+    }
+
+    public Map getParameterMap()
+    {
+        if (currentRequest == null || currentRequest != getRequest() )
+        {
+            // Cache the parameters for as long as the wrapped request stays the same.
+            // According to Servlet 2.3 SRV.6.2.2 the passed on ServletRequest object
+            // to an dispatched Servlet must remain the same (this one).
+            // Tomcat solves this by injecting a new ServletRequest of its own above
+            // this one (the getRequest() object).
+            // So, when that one has changed since the last time the parameters have 
+            // been accessed, flush the cache and rebuild the map.
+            currentRequest = getRequest();            
+            portletParameters = new HashMap();
+
+            // get portlet params
+            JetspeedRequestContext context = (JetspeedRequestContext) getAttribute("org.apache.jetspeed.request.RequestContext");
+            if (context != null)
+            {
+                PortalURL url = context.getPortalURL();
+                Iterator iter = url.getNavigationalState().getParameterNames(portletWindow);
+                while (iter.hasNext())
+                {
+                    String name = (String) iter.next();
+                    String[] values = url.getNavigationalState().getParameterValues(portletWindow, name);
+                    portletParameters.put(name, values);
+
+                }
+            }
+
+            //get servlet params
+            for (Enumeration parameters = getRequest().getParameterNames(); parameters.hasMoreElements();)
+            {
+                String paramName = (String) parameters.nextElement();
+                String[] paramValues = (String[]) getRequest().getParameterValues(paramName);
+                String[] values = (String[]) portletParameters.get(paramName);
+
+                if (getCharacterEncoding() != null)
+                {
+                    for (int i = 0; i < paramValues.length; i++)
+                    {
+                        try
+                        {
+                            paramValues[i] = new String(paramValues[i].getBytes("ISO-8859-1"), getCharacterEncoding());
+                        }
+                        catch (UnsupportedEncodingException e)
+                        {
+                            ;
+                        }
+                    }
+                }
+
+                if (values != null)
+                {
+                    String[] temp = new String[paramValues.length + values.length];
+                    System.arraycopy(paramValues, 0, temp, 0, paramValues.length);
+                    System.arraycopy(values, 0, temp, paramValues.length, values.length);
+                    paramValues = temp;
+                }
+                portletParameters.put(paramName, paramValues);
+            }
+        }
+        return Collections.unmodifiableMap(portletParameters);
+
+    }
+
+    public Enumeration getParameterNames()
+    {
+        return Collections.enumeration(this.getParameterMap().keySet());
+    }
+
+    public String[] getParameterValues( String name )
+    {
+        return (String[]) this.getParameterMap().get(name);
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getAttribute(java.lang.String)
+     */
+    public Object getAttribute( String name )
+    {
+        Object value = super.getAttribute(name);
+        if (name.equals(PortletRequest.USER_INFO))
+        {
+            JetspeedRequestContext context = (JetspeedRequestContext) getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
+            if (null != context)
+            {
+                String entityID = "--NULL--";
+                PortletEntity entity = portletWindow.getPortletEntity();
+                if (entity != null)
+                {
+                    entityID = entity.getId().toString();
+                }
+                PortletApplicationEntity portletAppEntity = portletWindow.getPortletEntity()
+                        .getPortletApplicationEntity();
+                PortletApplicationDefinition portletAppDef = entity.getPortletDefinition()
+                        .getPortletApplicationDefinition();
+
+                if (null != portletAppDef)
+                {
+                    value = context.getUserInfoMap(portletAppDef.getId());
+                    if (log.isDebugEnabled() && (null != value))
+                        log.debug(PortletRequest.USER_INFO + " map size: " + ((Map) value).size());
+                }
+                else
+                {
+                    log.error("Entity is null:" + entityID);
+                }
+
+            }
+        }
+        else
+        {
+            if (null == value)
+            {
+                PortletRequest pr = (PortletRequest) super.getAttribute("javax.portlet.request");
+                if (pr != null)
+                {
+                    value = super.getAttribute(nameSpaceMapper.encode(portletWindow.getId(),
+                            name));
+                }
+            }
+        }
+        return value;
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getLocale()
+     */
+    public Locale getLocale()
+    {
+        //Locale preferedLocale = (Locale) getSession().getAttribute(RequestContext.PREFERED_LOCALE_SESSION_KEY);
+        RequestContext requestContext = (RequestContext) _getHttpServletRequest().getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
+        Locale preferedLocale = requestContext.getLocale();
+        if (preferedLocale != null)
+        {
+            return preferedLocale;
+        }
+
+        return super.getLocale();
+    }
+
+    /**
+     * @see javax.servlet.ServletRequest#getLocales()
+     */
+    public Enumeration getLocales()
+    {
+        RequestContext requestContext = (RequestContext) _getHttpServletRequest().getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
+        Locale preferedLocale = requestContext.getLocale();
+        if (preferedLocale != null)
+        {
+            return getLocaleEnum(preferedLocale);
+        }
+
+        return super.getLocales();
+    }
+
+    /**
+     * <p>
+     * getLocaleEnum
+     * </p>
+     *
+     * @param preferedLocale
+     * @return
+     */
+    protected Enumeration getLocaleEnum( Locale preferedLocale )
+    {
+        ArrayList locales = new ArrayList();
+        locales.add(preferedLocale);
+        Enumeration localeEnums = super.getLocales();
+        while (localeEnums.hasMoreElements())
+        {
+            locales.add(localeEnums.nextElement());
+        }
+        Iterator i = locales.iterator();
+        return new Enumerator(locales);
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getHeader(java.lang.String)
+     */
+    public String getHeader( String name )
+    {
+        if(name.equals(ACCEPT_LANGUAGE))
+        {
+            return getLocale().getLanguage();   
+        }
+        else
+        {
+            return super.getHeader(name);
+        }
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getHeaders(java.lang.String)
+     */
+    public Enumeration getHeaders( String name )
+    {
+        if(name.equals(ACCEPT_LANGUAGE))
+        {      
+            return getLocaleEnum(getLocale());         
+        }
+        else
+        {
+            return super.getHeaders(name);
+        }        
+
+    }
+
+    /**
+     * <p>
+     * setAttribute
+     * </p>
+     * 
+     * @see javax.servlet.ServletRequest#setAttribute(java.lang.String,
+     *      java.lang.Object)
+     * @param arg0
+     * @param arg1
+     */
+    public void setAttribute( String name, Object value )
+    {
+        if (name == null)
+        {
+            throw new IllegalArgumentException("Attribute name == null");
+        }
+
+        // This allows us to make jetpseed objects avaiable to portlets
+        // This makes the portlet non-portable but is a must admin portlets
+        if (name.startsWith("org.apache.jetspeed"))
+        {
+            if (value == null)
+            {
+                this.removeAttribute(name);
+            }
+            else
+            {
+                String encodedKey = nameSpaceMapper.encode(portletWindow.getId(), name);
+                this._getHttpServletRequest().setAttribute(
+                        encodedKey, value);
+            }
+        }
+        super.setAttribute(name, value);
+    }
+    /**
+     * <p>
+     * getHeaderNames
+     * </p>
+     *
+     * @see javax.servlet.http.HttpServletRequest#getHeaderNames()
+     * @return
+     */
+    public Enumeration getHeaderNames()
+    {
+        return super.getHeaderNames();
+    }
+    
+    /*
+     * JST-168 PLT.16.3.3 cxxix
+     */
+  	public String getProtocol()
+  	{
+  			return null;
+  	}
+
+    /*
+     * JST-168 PLT.16.3.3 cxxix
+     */
+  	public String getRemoteAddr()
+  	{
+  			return null;
+  	}
+
+    /*
+     * JST-168 PLT.16.3.3 cxxix
+     */
+  	public String getRemoteHost()
+  	{
+  			return null;
+  	}
+
+    /*
+     * JST-168 PLT.16.3.3 cxxix
+     */
+  	public String getRealPath()
+  	{
+  			return null;
+  	}
+
+    /*
+     * JST-168 PLT.16.3.3 cxxix
+     */
+  	public StringBuffer getRequestURL()
+  	{
+  			return null;
+  	}
+
+    /*
+     * JST-168 PLT.16.3.3 cxxx
+     */
+    public String getPathInfo()
+  	{
+  			String attr = (String)super.getAttribute("javax.servlet.include.path_info");
+  			return (attr != null) ? attr : super.getPathInfo();
+  	}
+
+    /*
+     * JST-168 PLT.16.3.3 cxxx
+     */
+  	public String getPathTranslated()
+  	{
+  	    // TODO: Don't know yet how to implement this. 
+  	    //       A null value is a valid value. 
+  			return null;
+  	}
+
+    /*
+     * JST-168 PLT.16.3.3 cxxx
+     */
+  	public String getQueryString()
+  	{
+  			String attr = (String)super.getAttribute("javax.servlet.include.query_string");
+  			return (attr != null) ? attr : super.getQueryString();
+  	}
+
+    /*
+     * JST-168 PLT.16.3.3 cxxx
+     */
+  	public String getRequestURI()
+  	{
+  			String attr = (String)super.getAttribute("javax.servlet.include.request_uri");
+  			return (attr != null) ? attr : super.getRequestURI();
+  	}
+
+    /*
+     * JST-168 PLT.16.3.3 cxxx
+     */
+  	public String getServletPath()
+  	{
+  			String attr = (String)super.getAttribute("javax.servlet.include.servlet_path");
+  			return (attr != null) ? attr : super.getServletPath();
+  	}
+
+    /*
+     * JST-168 PLT.16.3.3 cxxxi
+     */
+  	public String getContextPath() 
+  	{
+       String attr = (String)super.getAttribute("javax.servlet.include.context_path");
+       return (attr != null) ? attr : super.getContextPath();
+  	}
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletResponseFactory.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletResponseFactory.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletResponseFactory.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletResponseFactory.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-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.jetspeed.engine.servlet;
+
+import javax.servlet.http.HttpServletResponse;
+import org.apache.pluto.factory.Factory;
+
+/**
+ * Factory interface for creating HTTP Request Wrappers
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: ServletResponseFactory.java 185962 2004-03-08 01:03:33Z jford $
+ */
+public interface ServletResponseFactory extends Factory
+{
+    public HttpServletResponse getServletResponse(HttpServletResponse response);
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletResponseFactoryImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletResponseFactoryImpl.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletResponseFactoryImpl.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletResponseFactoryImpl.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-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.jetspeed.engine.servlet;
+
+import java.util.Map;
+import javax.servlet.ServletConfig;
+
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Factory implementation for creating HTTP Response Wrappers
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: ServletResponseFactoryImpl.java 185962 2004-03-08 01:03:33Z jford $
+ */
+public class ServletResponseFactoryImpl
+    implements ServletResponseFactory
+{
+    private ServletConfig servletConfig;
+    
+    public void init(ServletConfig config, Map properties) 
+    throws Exception
+    {
+        servletConfig = config;
+    }
+    
+    public void destroy()
+    throws Exception
+    {
+
+    }
+
+    public javax.servlet.http.HttpServletResponse getServletResponse(HttpServletResponse response)
+    {
+        HttpServletResponse servletResponse = new ServletResponseImpl(response);
+        return servletResponse;
+    }
+    
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletResponseImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletResponseImpl.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletResponseImpl.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletResponseImpl.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-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.jetspeed.engine.servlet;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+/**
+ * Factory implementation for creating HTTP Response Wrappers
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: ServletResponseImpl.java 185962 2004-03-08 01:03:33Z jford $
+ */
+public class ServletResponseImpl
+    extends HttpServletResponseWrapper
+{
+    public ServletResponseImpl(HttpServletResponse response)
+    {
+        super(response);
+    }
+
+    private javax.servlet.http.HttpServletResponse _getHttpServletResponse()
+    {
+        return(HttpServletResponse) super.getResponse();
+    }
+
+    public void setResponse(HttpServletResponse response) 
+    {
+        super.setResponse(response);
+    }   
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2000-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.jetspeed.localization.impl;
+
+import java.util.Enumeration;
+import java.util.Locale;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.i18n.CurrentLocale;
+import org.apache.jetspeed.pipeline.PipelineException;
+import org.apache.jetspeed.pipeline.valve.AbstractValve;
+import org.apache.jetspeed.pipeline.valve.LocalizationValve;
+import org.apache.jetspeed.pipeline.valve.ValveContext;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * LocalizationValveImpl
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: LocalizationValveImpl.java 188377 2005-03-07 14:03:07Z ate $
+ */
+public class LocalizationValveImpl extends AbstractValve implements LocalizationValve
+{
+    private static final Log log = LogFactory.getLog(LocalizationValveImpl.class);
+    private Locale defaultLocale = null;
+    
+    public LocalizationValveImpl() {}
+    
+    public LocalizationValveImpl(String defaultLanguage)
+    {
+        String language = defaultLanguage != null ? defaultLanguage.trim() : "";
+        if (language.length()>0)
+        {
+            // Code taken from LocaleSelectorPorltet
+            String country = "";
+            String variant = "";
+            int countryIndex = language.indexOf('_');
+            if (countryIndex > -1)
+            {
+                country = language.substring(countryIndex + 1).trim();
+                language = language.substring(0, countryIndex).trim();
+                int vDash = country.indexOf("_");
+                if (vDash > 0)
+                {
+                    String cTemp = country.substring(0, vDash);
+                    variant = country.substring(vDash + 1);
+                    country = cTemp;
+                }
+            }
+
+            defaultLocale = new Locale(language, country, variant);
+            if ( defaultLocale.getLanguage().length() == 0 )
+            {
+                // not a valid language
+                defaultLocale = null;
+                log.warn("Invalid or unrecognized default language: "+language);
+            }
+            else
+            {
+                log.info("Default language set: "+defaultLocale);
+            }
+                
+        }
+    }
+    
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jetspeed.pipeline.valve.Valve#invoke(org.apache.jetspeed.request.RequestContext,
+     *      org.apache.jetspeed.pipeline.valve.ValveContext)
+     */
+    public void invoke( RequestContext request, ValveContext context ) throws PipelineException
+    {
+        // TODO Get the prefered locale from user's persistent storage if not anon user
+
+        Locale locale =
+            (Locale) request.getSessionAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE);
+
+        if ( locale == null && defaultLocale != null )
+        {
+            locale = defaultLocale;
+        }
+
+        if (locale == null)
+        {
+            locale = request.getRequest().getLocale();
+        }
+        
+        if (locale == null)
+        {
+            Enumeration preferedLocales = request.getRequest().getLocales();
+            while (preferedLocales.hasMoreElements() && locale == null)
+            {
+                locale = (Locale) preferedLocales.nextElement();
+            }
+        }
+
+        if (locale == null)
+        {
+            locale = Locale.getDefault();
+        }
+
+        request.setLocale(locale);
+        request.getRequest().setAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE, locale);
+        request.getRequest().getSession().setAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE, locale);
+        CurrentLocale.set(locale);
+       
+        // Pass control to the next Valve in the Pipeline
+        context.invokeNext(request);
+
+    }
+
+    public String toString()
+    {
+        return "LocalizationValve";
+    }
+
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginErrorServlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginErrorServlet.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginErrorServlet.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginErrorServlet.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2000-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.jetspeed.login;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+/**
+ * LoginErrorServlet
+ * 
+ * @author <a href="mailto:ate@douma.nu">Ate Douma </a>
+ * @version $Id: LoginErrorServlet.java 188346 2005-03-01 23:30:37Z taylor $
+ */
+public class LoginErrorServlet extends HttpServlet
+{
+
+    public void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws IOException, ServletException
+    {
+        HttpSession session = request.getSession();
+        String destination = (String) session
+                .getAttribute(LoginConstants.DESTINATION);
+        if (destination == null)
+            destination = request.getContextPath() + "/";
+        else
+            session.removeAttribute(LoginConstants.DESTINATION);
+
+        Integer retryCount = (Integer) session
+                .getAttribute(LoginConstants.RETRYCOUNT);
+        if (retryCount == null)
+            retryCount = new Integer(1);
+        else
+            retryCount = new Integer(retryCount.intValue() + 1);
+        session.setAttribute(LoginConstants.RETRYCOUNT, retryCount);
+
+        response.sendRedirect(response.encodeURL(destination));
+    }
+
+    public final void doPost(HttpServletRequest request,
+            HttpServletResponse response) throws IOException, ServletException
+    {
+        doGet(request, response);
+    }
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginProxyServlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginProxyServlet.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginProxyServlet.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginProxyServlet.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2000-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.jetspeed.login;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+/**
+ * LoginProxyServlet
+ * 
+ * @author <a href="mailto:ate@douma.nu">Ate Douma </a>
+ * @version $Id: LoginProxyServlet.java 188346 2005-03-01 23:30:37Z taylor $
+ */
+public class LoginProxyServlet extends HttpServlet
+{
+
+    public void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws IOException, ServletException
+    {
+        String parameter;
+
+        HttpSession session = request.getSession(true);
+
+        parameter = request.getParameter(LoginConstants.DESTINATION);
+        if (parameter != null)
+            session.setAttribute(LoginConstants.DESTINATION, parameter);
+        else
+            session.removeAttribute(LoginConstants.DESTINATION);
+        parameter = request.getParameter(LoginConstants.USERNAME);
+        if (parameter != null)
+            session.setAttribute(LoginConstants.USERNAME, parameter);
+        else
+            session.removeAttribute(LoginConstants.USERNAME);
+        parameter = request.getParameter(LoginConstants.PASSWORD);
+        if (parameter != null)
+            session.setAttribute(LoginConstants.PASSWORD, parameter);
+        else
+            session.removeAttribute(LoginConstants.PASSWORD);
+
+        response.sendRedirect(response.encodeURL(request.getContextPath()
+                + "/login/redirector"));
+    }
+
+    public final void doPost(HttpServletRequest request,
+            HttpServletResponse response) throws IOException, ServletException
+    {
+        doGet(request, response);
+    }
+
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginRedirectorServlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginRedirectorServlet.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginRedirectorServlet.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginRedirectorServlet.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2000-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.jetspeed.login;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+/**
+ * LoginRedirectorServlet
+ * 
+ * @author <a href="mailto:ate@douma.nu">Ate Douma </a>
+ * @version $Id: LoginRedirectorServlet.java 188598 2005-05-24 02:10:58Z ate $
+ */
+public class LoginRedirectorServlet extends HttpServlet
+{
+
+    public void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws IOException, ServletException
+    {
+        HttpSession session = request.getSession(true);
+        String destination = (String) session
+                .getAttribute(LoginConstants.DESTINATION);
+        if (destination == null || destination.equals(request.getContextPath()))
+            destination = request.getContextPath() + "/";
+        else
+            session.removeAttribute(LoginConstants.DESTINATION);
+
+        session.removeAttribute(LoginConstants.USERNAME);
+        session.removeAttribute(LoginConstants.PASSWORD);
+        session.removeAttribute(LoginConstants.RETRYCOUNT);
+        response.sendRedirect(response.encodeURL(destination));
+    }
+
+    public final void doPost(HttpServletRequest request,
+            HttpServletResponse response) throws IOException, ServletException
+    {
+        doGet(request, response);
+    }
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginServlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginServlet.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginServlet.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginServlet.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2000-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.jetspeed.login;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+/**
+ * LoginServlet
+ * 
+ * @author <a href="mailto:ate@douma.nu">Ate Douma </a>
+ * @version $Id: LoginServlet.java 188346 2005-03-01 23:30:37Z taylor $
+ */
+public class LoginServlet extends HttpServlet
+{
+
+    public void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws IOException, ServletException
+    {
+        HttpSession session = request.getSession(true);
+
+        if (request.getUserPrincipal() != null)
+        {
+            String destination = (String) session
+                    .getAttribute(LoginConstants.DESTINATION);
+            if (destination == null)
+                    destination = request.getContextPath() + "/";
+
+            response.sendRedirect(response.encodeURL(destination));
+        }
+
+        response.setContentType("text/html");
+        
+        PrintWriter out = response.getWriter();
+        out.print("<html>");
+        out.print("<body onLoad='document.forms[\"login\"].submit();'>");
+        out.print("<form id='login' method='POST' action='"
+                + response.encodeURL("j_security_check") + "'>");
+        out.print("<input type='hidden' name='j_username' value='"
+                + session.getAttribute(LoginConstants.USERNAME) + "'>");
+        out.print("<input type='hidden' name='j_password' value='"
+                + session.getAttribute(LoginConstants.PASSWORD) + "'>");
+        out.print("</form>");
+        out.print("</body>");
+        out.print("</html>");
+        out.close();
+    }
+
+    public final void doPost(HttpServletRequest request,
+            HttpServletResponse response) throws IOException, ServletException
+    {
+        doGet(request, response);
+    }
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LogoutServlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LogoutServlet.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LogoutServlet.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LogoutServlet.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2000-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.jetspeed.login;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * LogoutServlet
+ * 
+ * @author <a href="mailto:ate@douma.nu">Ate Douma </a>
+ * @version $Id: LogoutServlet.java 188346 2005-03-01 23:30:37Z taylor $
+ */
+public class LogoutServlet extends HttpServlet
+{
+
+    public void doGet(HttpServletRequest request,
+            HttpServletResponse response) throws IOException, ServletException
+    {
+        request.getSession(true).invalidate();
+        response.sendRedirect(response.encodeURL(request.getContextPath()));
+    }
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/manager/ManagerServlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/manager/ManagerServlet.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/manager/ManagerServlet.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/manager/ManagerServlet.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,427 @@
+/*
+ * Copyright 2000-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.jetspeed.manager;
+
+import java.io.CharArrayWriter;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.fileupload.DiskFileUpload;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileUpload;
+import org.apache.jetspeed.Jetspeed;
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.components.portletregistry.RegistryException;
+import org.apache.jetspeed.deployment.DeploymentManager;
+import org.apache.jetspeed.deployment.DeploymentStatus;
+import org.apache.jetspeed.factory.PortletFactory;
+import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
+import org.apache.jetspeed.om.common.portlet.PortletApplication;
+import org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager;
+import org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManagerResult;
+
+/**
+ * ManagerServlet ala Tomcat ManagerServlet 
+ *
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id: ManagerServlet.java 188638 2005-06-02 09:00:35Z ate $
+ */
+public class ManagerServlet extends HttpServlet
+{
+    private static int               OK                    = 0;
+    private static int               ERROR_NO_DATA         = 1;
+    private static int               ERROR_UNKNOWN_COMMAND = 2;
+    private static int               ERROR_UNKNOWN_PA      = 3;
+    private static int               ERROR_INVALID         = 4;
+    private static int               ERROR_UNSUPPORTED     = 5;
+    private static int               ERROR_UNAVAILABLE     = 6;
+    private static int               ERROR_SERVER          = 7;
+    private static int               ERROR_UNEXPECTED      = 8;
+    private static int               ERROR_IGNORED         = 9;
+
+    private ApplicationServerManager asm;
+    private PortletRegistry          registry;
+    private PortletFactory           portletFactory;
+    private DeploymentManager        dm;
+
+    public void init() throws ServletException
+    {
+        super.init();
+        asm = (ApplicationServerManager) Jetspeed.getComponentManager().getComponent(ApplicationServerManager.class);
+        registry = (PortletRegistry) Jetspeed.getComponentManager().getComponent(PortletRegistry.class);
+        portletFactory = (PortletFactory) Jetspeed.getComponentManager().getComponent("portletFactory");
+        dm = (DeploymentManager) Jetspeed.getComponentManager().getComponent("deploymentManager");
+    }
+
+    public void destroy()
+    {
+        super.destroy();
+    }
+
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+    {
+        process(request, response, false);
+    }
+
+    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+    {
+        process(request, response, true);
+    }
+
+    protected void process(HttpServletRequest request, HttpServletResponse response, boolean posted)
+                    throws ServletException, IOException
+    {
+        // Prepare our output writer to generate the response message
+        response.setContentType("text/plain; charset=utf-8");
+        StringBuffer output = new StringBuffer();
+        CharArrayWriter buffer = new CharArrayWriter();
+        PrintWriter writer = new PrintWriter(buffer);
+
+        // Identify the request parameters that we need
+        String command = request.getPathInfo();
+        int result = OK;
+
+        if (command == null)
+        {
+            result = OK;
+        }
+        else if (command.equals("/list"))
+        {
+            result = list(writer);
+        }
+        else if (command.equals("/start"))
+        {
+            result = start(writer, request.getParameter("pa"));
+        }
+        else if (command.equals("/stop"))
+        {
+            result = stop(writer, request.getParameter("pa"));
+        }
+        else if (command.equals("/undeploy"))
+        {
+            result = undeploy(writer, request.getParameter("pa"));
+        }
+        else if (command.equals("/unregister"))
+        {
+            result = unregister(writer, request.getParameter("pa"));
+        }
+        else if (command.equals("/deploy"))
+        {
+            if (posted)
+            {
+                result = deploy(writer, request);
+            }
+            else
+            {
+                writer.println("Error: /deploy is only available through POST");
+                result = ERROR_INVALID;
+            }
+        }
+        else
+        {
+            writer.println("Error: Unknown command " + command);
+            result = ERROR_UNKNOWN_COMMAND;
+        }
+        writer.flush();
+        writer.close();
+        writer = response.getWriter();
+        if (result == OK)
+        {
+            writer.println("OK");
+        }
+        else
+        {
+            writer.println("FAIL - CODE: " + result);
+        }
+        writer.print(buffer.toString());
+        writer.flush();
+        writer.close();
+    }
+
+    protected int list(PrintWriter writer)
+    {
+        writer.println("Listed Portlet Applications");
+        Iterator iter = registry.getPortletApplications().iterator();
+        PortletApplication pa;
+        while (iter.hasNext())
+        {
+            pa = (PortletApplication) iter.next();
+            writer.println(pa.getId() + ":" + pa.getName() + ":" + pa.getWebApplicationDefinition().getContextRoot()
+                           + ":" + (portletFactory.isPortletApplicationRegistered(pa) ? "ACTIVE" : "INACTIVE"));
+        }
+        return OK;
+    }
+
+    protected int start(PrintWriter writer, String paName)
+    {
+        PortletApplication pa = null;
+        if (paName != null)
+        {
+            pa = registry.getPortletApplication(paName);
+        }
+        if (pa == null)
+        {
+            writer.println("Error: Unknown Portlet Application " + paName);
+            return ERROR_UNKNOWN_PA;
+        }
+        if (portletFactory.isPortletApplicationRegistered(pa))
+        {
+            writer.println("Warning: Portlet Application " + paName + " already started");
+            return OK;
+        }
+        else if (pa.getApplicationType() == MutablePortletApplication.LOCAL)
+        {
+            writer.println("Error: Starting LOCAL Portlet Application " + paName + " not supported");
+            return ERROR_UNSUPPORTED;
+        }
+        else if (!asm.isConnected())
+        {
+            writer.println("Error: Not connected to the server");
+            return ERROR_UNAVAILABLE;
+        }
+        else
+        {
+            String response = null;
+            try
+            {
+                ApplicationServerManagerResult result = asm.start(pa.getWebApplicationDefinition().getContextRoot());
+                if (result.isOk())
+                {
+                    writer.println("Portlet Application " + paName + " started");
+                    writer.println(result.getResponse());
+                    return OK;
+                }
+                else
+                {
+                    writer.println("Error: Portlet Application " + paName + " could not be started");
+                    writer.println(result.getResponse());
+                    return ERROR_SERVER;
+                }
+            }
+            catch (Exception e)
+            {
+                writer.println("Error: Failed to start Portlet Application " + paName + ": " + e.getMessage());
+                e.printStackTrace(writer);
+                return ERROR_UNEXPECTED;
+            }
+        }
+    }
+
+    protected int stop(PrintWriter writer, String paName)
+    {
+        PortletApplication pa = null;
+        if (paName != null)
+        {
+            pa = registry.getPortletApplication(paName);
+        }
+        if (pa == null)
+        {
+            writer.println("Error: Unknown Portlet Application " + paName);
+            return ERROR_UNKNOWN_PA;
+        }
+        if (!portletFactory.isPortletApplicationRegistered(pa))
+        {
+            writer.println("Portlet Application " + paName + " already stopped");
+            return OK;
+        }
+        else if (pa.getApplicationType() == MutablePortletApplication.LOCAL)
+        {
+            writer.println("Error: Stopping LOCAL Portlet Application " + paName + " not supported");
+            return ERROR_UNSUPPORTED;
+        }
+        else if (!asm.isConnected())
+        {
+            writer.println("Error: Not connected to the server");
+            return ERROR_UNAVAILABLE;
+        }
+        else
+        {
+            String response = null;
+            try
+            {
+                ApplicationServerManagerResult result = asm.stop(pa.getWebApplicationDefinition().getContextRoot());
+                if (result.isOk())
+                {
+                    writer.println("Portlet Application " + paName + " stopped");
+                    writer.println(result.getResponse());
+                    return OK;
+                }
+                else
+                {
+                    writer.println("Error: Portlet Application " + paName + " could not be stopped");
+                    writer.println(result.getResponse());
+                    return ERROR_SERVER;
+                }
+            }
+            catch (Exception e)
+            {
+                writer.println("Error: Failed to stop Portlet Application " + paName + ": " + e.getMessage());
+                e.printStackTrace(writer);
+                return ERROR_UNEXPECTED;
+            }
+        }
+    }
+
+    protected int undeploy(PrintWriter writer, String paName)
+    {
+        int stopResult = stop(writer, paName);
+        if (stopResult != OK)
+        {
+            return stopResult;
+        }
+        else if (!asm.isConnected())
+        {
+            writer.println("Error: Not connected to the server");
+            return ERROR_UNAVAILABLE;
+        }
+
+        PortletApplication pa = registry.getPortletApplication(paName);
+        String response = null;
+        try
+        {
+            ApplicationServerManagerResult result = asm.undeploy(pa.getWebApplicationDefinition().getContextRoot());
+            if (result.isOk())
+            {
+                writer.println("Portlet Application " + paName + " undeployed");
+                writer.println(result.getResponse());
+                return OK;
+            }
+            else
+            {
+                writer.println("Error: Portlet Application " + paName + " could not be undeployed");
+                writer.println(result.getResponse());
+                return ERROR_SERVER;
+            }
+        }
+        catch (Exception e)
+        {
+            writer.println("Error: Failed to undeploy Portlet Application " + paName + ": " + e.getMessage());
+            e.printStackTrace(writer);
+            return ERROR_UNEXPECTED;
+        }
+    }
+
+    protected int unregister(PrintWriter writer, String paName)
+    {
+        int result = stop(writer, paName);
+
+        if (result != OK)
+        {
+            return result;
+        }
+
+        PortletApplication pa = registry.getPortletApplication(paName);
+        try
+        {
+            registry.removeApplication(pa);
+            writer.println("Portlet Application " + paName + " unregistered");
+            return OK;
+        }
+        catch (RegistryException e)
+        {
+            writer.println("Error: Failed to unregister Portlet Application " + paName + ": " + e.getMessage());
+            e.printStackTrace(writer);
+            return ERROR_UNEXPECTED;
+        }
+    }
+
+    protected int deploy(PrintWriter writer, HttpServletRequest request)
+    {
+        if (  !FileUpload.isMultipartContent(request) )
+        {
+            writer.println("Error: No file multipart content provided");
+            return ERROR_NO_DATA;
+        }
+        File tempDir = null;
+        File tempFile = null;
+
+        try
+        {
+            DiskFileUpload upload = new DiskFileUpload();
+            tempDir = File.createTempFile("upload", null);
+            tempDir.deleteOnExit();
+            tempDir.delete();
+            tempDir.mkdirs();
+            tempDir.deleteOnExit();
+            List items = upload.parseRequest(request,0,-1L,tempDir.getAbsolutePath());
+            Iterator iter = items.iterator();
+            while ( iter.hasNext() )
+            {
+                FileItem item = (FileItem)iter.next();
+                if (!item.isFormField())
+                {
+                    String fileName = item.getName();
+                    tempFile = new File(tempDir, fileName );
+                    tempFile.deleteOnExit();
+                    item.write(tempFile);
+
+                    try
+                    {
+                        DeploymentStatus status = dm.deploy(tempFile);
+                        if ( status.getStatus() == DeploymentStatus.STATUS_OKAY )
+                        {
+                            writer.println("Deployed " + fileName);
+                            return OK;
+                        }
+                        else if ( status.getStatus() == DeploymentStatus.STATUS_EVAL )
+                        {
+                            writer.println("Error: Unrecognized file "+ fileName);
+                            return ERROR_IGNORED;
+                        }
+                        else
+                        {
+                            writer.println("Error: Failed to deploy file "+ fileName);
+                            return ERROR_IGNORED;
+                        }                    
+                    }
+                    catch (Throwable e)
+                    {
+                        writer.println("Error: Failed to deploy file " + fileName + ": " + e.getMessage());
+                        e.printStackTrace(writer);
+                        return ERROR_UNEXPECTED;
+                    }
+                }
+            }
+
+        }
+        catch (Throwable e)
+        {
+            writer.println("Error: Failed to process uploaded data: "+e.getMessage());
+            e.printStackTrace(writer);
+            return ERROR_UNEXPECTED;
+        }
+        finally
+        {
+            if (tempFile != null)
+            {
+                tempFile.delete();
+            }
+            if (tempDir != null)
+            {
+                tempDir.delete();
+            }
+        }
+        return OK;
+    }
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/pipeline/JetspeedPipeline.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/pipeline/JetspeedPipeline.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/pipeline/JetspeedPipeline.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/pipeline/JetspeedPipeline.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2000-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.jetspeed.pipeline;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.pipeline.valve.Valve;
+import org.apache.jetspeed.pipeline.valve.ValveContext;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * Flexible implementation of a {@link org.apache.jetspeed.pipeline.Pipeline}.
+ *
+ * <br/><br/>
+ * Suggested order of valves:
+ * <ul>
+ * <li>ContainerValve</li>
+ * <li>CapabilityValve</li>
+ * <li>UserProfilerValve</li>
+ * <li>PageProfilerValve</li>
+ * <li>ActionValve</li>
+ * <li>LayoutValve</li>
+ * <li>ContentValve</li>
+ * <li>AggregateValve</li>
+ * <li>CleanupValve</li>
+ * </ul>
+ *
+ * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
+ * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
+ * @version $Id: JetspeedPipeline.java 188451 2005-03-27 21:38:32Z ate $
+ */
+public class JetspeedPipeline
+implements Pipeline, ValveContext
+{
+    /** Logger */
+    private Log log = LogFactory.getLog(JetspeedPipeline.class);
+    
+    /** Name of this pipeline. */
+    protected String name;
+    
+    /** The set of Valves associated with this Pipeline. */
+    protected Valve[] valves = new Valve[0];
+    
+    /**
+     * The per-thread execution state for processing through this
+     * pipeline.  The actual value is a java.lang.Integer object
+     * containing the subscript into the <code>values</code> array, or
+     * a subscript equal to <code>values.length</code> if the basic
+     * Valve is currently being processed.
+     *
+     */
+    protected ThreadLocal state = new ThreadLocal();
+    
+    /**
+     * Constructor that provides the descriptor for building
+     * the pipeline
+     */
+    public JetspeedPipeline(String name, List valveList)
+    throws Exception
+    {
+        valves = (Valve[]) valveList.toArray(new Valve[valveList.size()]);
+        setName(name);
+    }
+    
+    /**
+     * @see org.apache.plexus.summit.Pipeline#init()
+     */
+    public void initialize()
+    throws PipelineException
+    {
+        
+       
+    }
+    
+    /**
+     * Set the name of this pipeline.
+     *
+     * @param name Name of this pipeline.
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+    
+    /**
+     * Get the name of this pipeline.
+     *
+     * @return String Name of this pipeline.
+     */
+    public String getName()
+    {
+        return name;
+    }
+    
+    /**
+     * @see org.apache.plexus.summit.Pipeline#addValve(Valve)
+     */
+    public void addValve(Valve valve)
+    {
+        // Add this Valve to the set associated with this Pipeline
+        synchronized (valves)
+        {
+            Valve[] results = new Valve[valves.length + 1];
+            System.arraycopy(valves, 0, results, 0, valves.length);
+            results[valves.length] = valve;
+            valves = results;
+        }
+    }
+    
+    /**
+     * @see org.apache.plexus.summit.Pipeline#getValves()
+     */
+    public Valve[] getValves()
+    {
+        synchronized (valves)
+        {
+            Valve[] results = new Valve[valves.length];
+            System.arraycopy(valves, 0, results, 0, valves.length);
+            return results;
+        }
+    }
+    
+    /**
+     * @see org.apache.plexus.summit.Pipeline#removeValve(Valve)
+     */
+    public void removeValve(Valve valve)
+    {
+        synchronized (valves)
+        {
+            // Locate this Valve in our list
+            int index = -1;
+            for (int i = 0; i < valves.length; i++)
+            {
+                if (valve == valves[i])
+                {
+                    index = i;
+                    break;
+                }
+            }
+            if (index < 0)
+            {
+                return;
+            }
+            
+            // Remove this valve from our list
+            Valve[] results = new Valve[valves.length - 1];
+            int n = 0;
+            for (int i = 0; i < valves.length; i++)
+            {
+                if (i == index)
+                {
+                    continue;
+                }
+                results[n++] = valves[i];
+            }
+            valves = results;
+        }
+    }
+    
+    /**
+     * @see org.apache.plexus.summit.Pipeline#invoke(RequestContext)
+     */
+    public void invoke(RequestContext request)
+    throws PipelineException
+    {
+        // Initialize the per-thread state for this thread
+        state.set(new Integer(0));
+        
+        // Invoke the first Valve in this pipeline for this request
+        invokeNext(request);
+    }
+    
+    /**
+     * @see org.apache.plexus.summit.ValveContext#invokeNext(RequestContext)
+     */
+    public void invokeNext(RequestContext request)
+    throws PipelineException
+    {
+        // Identify the current subscript for the current request thread
+        Integer current = (Integer) state.get();
+        int subscript = current.intValue();
+        
+        if (subscript < valves.length)
+        {
+            // Invoke the requested Valve for the current request
+            // thread and increment its thread-local state.
+            state.set(new Integer(subscript + 1));
+            valves[subscript].invoke(request, this);
+        }
+    }
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/pipeline/Pipeline.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/pipeline/Pipeline.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/pipeline/Pipeline.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/pipeline/Pipeline.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2000-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.jetspeed.pipeline;
+
+import java.io.IOException;
+
+import org.apache.jetspeed.pipeline.valve.Valve;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ *
+ * NOTE: This class will be deprecated once we merge with Summit
+ *
+ * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
+ * @version $Id: Pipeline.java 187173 2004-08-01 23:17:25Z weaver $
+ */
+public interface Pipeline
+{
+    void initialize()
+        throws PipelineException;
+    /**
+     * <p>Add a new Valve to the end of the pipeline.</p>
+     *
+     * @param valve Valve to be added.
+     *
+     * @exception IllegalStateException If the pipeline has not been
+     * initialized.
+     */
+    void addValve(Valve valve);
+
+    /**
+     * <p>Return the set of all Valves in the pipeline.  If there are no
+     * such Valves, a zero-length array is returned.</p>
+     *
+     * @return An array of valves.
+     */
+    Valve[] getValves();
+
+    /**
+     * <p>Cause the specified request and response to be processed by
+     * the sequence of Valves associated with this pipeline, until one
+     * of these Valves decides to end the processing.</p>
+     *
+     * <p>The implementation must ensure that multiple simultaneous
+     * requests (on different threads) can be processed through the
+     * same Pipeline without interfering with each other's control
+     * flow.</p>
+     *
+     * @param data The run-time information, including the servlet
+     * request and response we are processing.
+     *
+     * @exception IOException an input/output error occurred.
+     */
+    void invoke(RequestContext context)
+        throws PipelineException;
+
+    /**
+     * <p>Remove the specified Valve from the pipeline, if it is found;
+     * otherwise, do nothing.</p>
+     *
+     * @param valve Valve to be removed.
+     */
+    void removeValve(Valve valve);
+
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/pipeline/PipelineException.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/pipeline/PipelineException.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/pipeline/PipelineException.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/pipeline/PipelineException.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2000-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.jetspeed.pipeline;
+import org.apache.jetspeed.exception.JetspeedException;
+
+/**
+  * Occurs when anything unexpected happens within Jetspeed and the Pipeline.
+  *
+  * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
+  * @version $Id: PipelineException.java 186726 2004-06-05 05:13:09Z taylor $
+  */
+
+public class PipelineException extends JetspeedException
+ {
+
+    public PipelineException() 
+    {
+        super();
+    }
+
+    public PipelineException( String message )
+    {
+        super( message );
+    }
+
+    public PipelineException(Throwable nested)
+    {
+        super(nested);
+    }
+    
+    public PipelineException(String msg, Throwable nested)
+    {
+        super(msg, nested);
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message