You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by at...@apache.org on 2009/03/06 17:11:52 UTC

svn commit: r750954 [2/5] - in /portals/pluto/trunk: pluto-container/src/main/java/org/apache/pluto/core/ pluto-container/src/main/java/org/apache/pluto/descriptors/portlet/ pluto-container/src/main/java/org/apache/pluto/descriptors/services/jaxb/ plut...

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/ClientDataRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/ClientDataRequestImpl.java?rev=750954&r1=750953&r2=750954&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/ClientDataRequestImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/ClientDataRequestImpl.java Fri Mar  6 16:11:51 2009
@@ -17,198 +17,92 @@
 
 package org.apache.pluto.internal.impl;
 
+import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
+import java.io.UnsupportedEncodingException;
 
 import javax.portlet.ClientDataRequest;
-import javax.servlet.http.HttpServletRequest;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pluto.PortletContainer;
-import org.apache.pluto.PortletWindow;
-import org.apache.pluto.util.ArgumentUtility;
+import org.apache.pluto.spi.optional.PortletRequestContext;
 
 /**
  * Implementation of the <code>javax.portlet.ClientDataRequest</code> interface.
  */
-public abstract class ClientDataRequestImpl extends PortletRequestImpl
-        implements ClientDataRequest
+public abstract class ClientDataRequestImpl extends PortletRequestImpl implements ClientDataRequest
 {
+    /** Flag indicating if the HTTP body reader has been accessed. */
+    protected boolean readerAccessed = false;
 
-    /** Logger. */
-    private static final Log LOG = LogFactory
-            .getLog(ClientDataRequestImpl.class);
-
-    public ClientDataRequestImpl(PortletContainer container,
-            PortletWindow portletWindow, HttpServletRequest servletRequest)
+    public ClientDataRequestImpl(PortletRequestContext requestContext, String lifecyclePhase)
     {
-        super(container, portletWindow, servletRequest);
+        super(requestContext, lifecyclePhase);
     }
 
-    public InputStream getPortletInputStream() throws IOException
+    private void checkPostedFormData() 
     {
-        HttpServletRequest servletRequest = (HttpServletRequest) getRequest();
-        if (servletRequest.getMethod().equals("POST"))
+        if (getMethod().equals("POST"))
         {
-            String contentType = servletRequest.getContentType();
-            if (contentType == null
-                    || contentType.equals("application/x-www-form-urlencoded")) { throw new IllegalStateException(
-                    "User request HTTP POST data is of type "
-                            + "application/x-www-form-urlencoded. "
-                            + "This data has been already processed "
-                            + "by the portal/portlet-container and is available "
-                            + "as request parameters."); }
+            String contentType = getContentType();
+            if (contentType == null || contentType.equals("application/x-www-form-urlencoded"))
+            {
+                throw new IllegalStateException("User request HTTP POST data is of type "
+                                                + "application/x-www-form-urlencoded. "
+                                                + "This data has been already processed "
+                                                + "by the portlet-container and is available "
+                                                + "as request parameters.");
+            }
         }
-        return servletRequest.getInputStream();
-    }
-
-    public void setCharacterEncoding(String encoding)
-            throws java.io.UnsupportedEncodingException
-    {
-        super.setCharacterEncoding(encoding);
-    }
-
-    public java.io.BufferedReader getReader()
-            throws java.io.UnsupportedEncodingException, java.io.IOException
-    {
-        return super.getReader();
     }
-
+        
     public java.lang.String getCharacterEncoding()
     {
-        return super.getCharacterEncoding();
-    }
-
-    public java.lang.String getContentType()
-    {
-        return super.getContentType();
+        return getServletRequest().getCharacterEncoding();
     }
 
     public int getContentLength()
     {
-        return super.getContentLength();
+        return getServletRequest().getContentLength();
     }
 
-    public String getMethod()
-    {
-        return super.getMethod();
-    }
-
-    @Override
-    public String getParameter(String name)
+    public java.lang.String getContentType()
     {
-        ArgumentUtility.validateNotNull("parameterName", name);
-        String[] values  = null;
-        if (parameters != null)
-        {
-            values = parameters.get(name);
-        }
-        else
-        {
-            values = mergeParameters().get(name);
-        }
-        if (values != null && values.length > 0) 
-        {
-            return values[0];
-        } 
-        return null;
+        return getServletRequest().getContentType();
     }
     
-    @Override
-    public Enumeration<String> getParameterNames() 
+    public String getMethod()
     {
-        if (parameters != null)
-        {
-            return Collections.enumeration(parameters.keySet());
-        }
-        return Collections.enumeration(mergeParameters().keySet());
+        return getServletRequest().getMethod();
     }
-    
 
-    @Override
-    public Map<String, String[]> getParameterMap()
+    public InputStream getPortletInputStream() throws IOException
     {
-        if (parameters != null)
-        {
-            return parameters;
-        }
-        return Collections.unmodifiableMap(mergeParameters());
+        checkPostedFormData();
+        // the HttpServletRequest will ensure that a IllegalStateException is thrown
+        //   if getReader() was called earlier        
+        return getServletRequest().getInputStream();
     }
 
-    @Override
-    public String[] getParameterValues(String name)
-    {
-        ArgumentUtility.validateNotNull("parameterName", name);
-        String[] values  = null;
-        if (parameters != null)
-        {
-            values = parameters.get(name);
-        }
-        else
-        {
-            values = mergeParameters().get(name);
-        }
-        return values;
-    }
+    public BufferedReader getReader()
+    throws UnsupportedEncodingException, IOException 
+    {
+        checkPostedFormData();
+        // the HttpServletRequest will ensure that a IllegalStateException is thrown
+        //   if getInputStream() was called earlier
+        BufferedReader reader = getServletRequest().getReader();
+        readerAccessed = true;
+        return reader;
 
-    /**
-     * Iterate over the private and the public parameter list and merge it.
-     * 
-     * @return merged list
-     */
-    private Map<String, String[]> mergeParameters()
-    {
-        Map<String, String[]> mergedParameterMap = new HashMap<String, String[]>();
-        // Put the private list first into the map, because it is required, this
-        // parameters are the first in the value array.
-        if (super.getPrivateParameterMap() != null)
-            mergedParameterMap.putAll(super.getPrivateParameterMap());
-        Map<String, String[]> publicParameterMap = super
-                .getPublicParameterMap();
-         //Iterate over the public parameter list
-        if (publicParameterMap != null)
+    }
+    
+    public void setCharacterEncoding(String encoding)
+    throws UnsupportedEncodingException 
+    {
+        if (readerAccessed) 
         {
-            Set keySet = publicParameterMap.keySet();
-            if (keySet != null)
-            {
-                Iterator<String> iterator = keySet.iterator();
-                while (iterator.hasNext())
-                {
-                    String name = iterator.next();
-                     //tests if the name already exist
-                    if (mergedParameterMap.containsKey(name))
-                    {
-                        String[] tmp = mergedParameterMap.get(name);
-                        String[] tmp2 = publicParameterMap.get(name);
-                        String[] values = new String[tmp.length + tmp2.length];
-                        int length = tmp.length;
-                        for (int i = 0; i < length; i++)
-                        {
-                            values[i] = tmp[i];
-                        }
-                        for (int i = 0; i < tmp2.length; i++)
-                        {
-                            values[i + length] = tmp2[i];
-                        }
-                        mergedParameterMap.put(name, values);
-                    }
-                    else
-                    {
-                        mergedParameterMap.put(name, publicParameterMap
-                                .get(name));
-                    }
-                }
-            }
+            throw new IllegalStateException("Cannot set character encoding "
+                    + "after HTTP body reader is accessed.");
         }
-        this.parameters = mergedParameterMap;
-        return this.parameters;
+        getServletRequest().setCharacterEncoding(encoding);
     }
-
 }

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventRequestImpl.java?rev=750954&r1=750953&r2=750954&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventRequestImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventRequestImpl.java Fri Mar  6 16:11:51 2009
@@ -17,99 +17,33 @@
 package org.apache.pluto.internal.impl;
 
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
 import javax.portlet.Event;
 import javax.portlet.EventRequest;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.HttpServletRequest;
+import javax.portlet.PortletRequest;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pluto.Constants;
-import org.apache.pluto.PortletContainer;
-import org.apache.pluto.PortletWindow;
-import org.apache.pluto.internal.InternalEventRequest;
+import org.apache.pluto.spi.optional.PortletRequestContext;
 
 /**
  * <code>javax.portlet.EventRequest</code> implementation.
- * This class also implements InternalEventRequest.
  *
- * @author <a href="mailto:chrisra@cs.uni-jena.de">Christian Raschka</a>
  */
-public class EventRequestImpl extends PortletRequestImpl 
-		implements EventRequest, InternalEventRequest {
-
-	/** Logger. */
-    private static final Log LOG = LogFactory.getLog(ActionRequestImpl.class);
-	
-	//	 Private Member Variables ------------------------------------------------	
-    	
-	private Event event; 
+public class EventRequestImpl extends PortletRequestImpl implements EventRequest
+{
+	private final Event event; 
 	
-	//	 Constructor -------------------------------------------------------------
-    
-    public EventRequestImpl(PortletContainer container,
-                             PortletWindow portletWindow,
-                             HttpServletRequest servletRequest, Event event) {
-        super(container, portletWindow, servletRequest);
+    public EventRequestImpl(PortletRequestContext requestContext, Event event)
+    {
+        super(requestContext, PortletRequest.EVENT_PHASE);
         this.event = event;
-        if (LOG.isDebugEnabled()) {
-        	LOG.debug("Created Event request for: " + portletWindow);
-        }
-   
     }
     
-    //  EventRequest impl -------------------------------------------------------
-    
-    protected Integer getRequestMethod()
+    public Event getEvent()
     {
-        return Constants.METHOD_EVENT; 
-    }
-    
-    public Event getEvent(){
         return event;
     }
-    
-    //  PortletRequestImpl impl -------------------------------------------------
-    
-	public String getLifecyclePhase() {
-		return EVENT_PHASE;
-	}
 
-	
-    
-    //////////////////////////////////////////////////////////////////
-	//for forward and include
-	//////////////////////////////////////////////////////////////////
-	
-	public String getCharacterEncoding() {
-        return (super.isIncluded() || super.isForwarded()) ? null : super.getCharacterEncoding();
-    }
-	
-	public int getContentLength() {
-        return (super.isIncluded() || super.isForwarded()) ? 0 : super.getContentLength();
-    }
-	
-	public String getContentType() {
-        return (super.isIncluded() || super.isForwarded()) ? null : super.getContentType();
-    }
-	
-	public ServletInputStream getInputStream() throws IOException {
-        return (super.isIncluded() || super.isForwarded()) ? null : super.getInputStream();
-    }
-	
-	public BufferedReader getReader()
-    throws UnsupportedEncodingException, IOException {
-        return (super.isIncluded() || super.isForwarded()) ? null : super.getReader();
-    }
-	
-	public void setCharacterEncoding(String encoding)
-    throws UnsupportedEncodingException {
-        if (!super.isIncluded() && !super.isForwarded()) {
-        	super.setCharacterEncoding(encoding);
-        }
+    public String getMethod()
+    {
+        return getServletRequest().getMethod();
     }
 }

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventResponseImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventResponseImpl.java?rev=750954&r1=750953&r2=750954&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventResponseImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventResponseImpl.java Fri Mar  6 16:11:51 2009
@@ -16,16 +16,14 @@
 
 package org.apache.pluto.internal.impl;
 
-import java.io.IOException;
+import java.util.Map;
 
 import javax.portlet.EventRequest;
 import javax.portlet.EventResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
-import org.apache.pluto.PortletContainer;
-import org.apache.pluto.PortletWindow;
-import org.apache.pluto.internal.InternalEventResponse;
+import org.apache.pluto.spi.optional.PortletEventResponseContext;
+import org.apache.pluto.spi.optional.PortletStateAwareResponseContext;
+import org.apache.pluto.util.ArgumentUtility;
 
 /**
  * Implementation of JSR-286 <code>EventResponse</code>.
@@ -33,26 +31,22 @@
  * @since 2.0
  */
 
-public class EventResponseImpl extends StateAwareResponseImpl
-	implements EventResponse,InternalEventResponse {
-
-    public EventResponseImpl(PortletContainer container,
-                              PortletWindow portletWindow,
-                              HttpServletRequest servletRequest,
-                              HttpServletResponse servletResponse) {
-        super(container, portletWindow, servletRequest,
-              servletResponse);
+public class EventResponseImpl extends StateAwareResponseImpl implements EventResponse
+{
+    public EventResponseImpl(PortletEventResponseContext responseContext)
+    {
+        super(responseContext);
+    }
+    
+    protected void checkSetStateChanged()
+    {
+        // nothing to check or do for EventResponse
     }
 
-	public void setRenderParameters(EventRequest request) {
-		super.setEventRequest(request);
-	}
-
-	@Override
-	public void sendRedirect(String location) throws IOException {
-		if (super.isForwarded() || super.isIncluded()){
-			// no operation
-		}
-		super.sendRedirect(location);
+	public void setRenderParameters(EventRequest request)
+	{
+        ArgumentUtility.validateNotNull("request", request);
+	    Map<String, String[]> parameters = ((PortletStateAwareResponseContext)getResponseContext()).getRenderParameters();
+	    parameters.putAll(request.getParameterMap());
 	}
 }

Added: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/HttpServletPortletRequestWrapper.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/HttpServletPortletRequestWrapper.java?rev=750954&view=auto
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/HttpServletPortletRequestWrapper.java (added)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/HttpServletPortletRequestWrapper.java Fri Mar  6 16:11:51 2009
@@ -0,0 +1,594 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.pluto.internal.impl;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.portlet.ClientDataRequest;
+import javax.portlet.PortletRequest;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpSession;
+
+import org.apache.pluto.Constants;
+import org.apache.pluto.internal.RequestDispatcherPathInfo;
+import org.apache.pluto.spi.optional.PortletRequestContext;
+
+/**
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id$
+ */
+public class HttpServletPortletRequestWrapper extends HttpServletRequestWrapper
+{
+    private static class PortletRequestParametersWrapper extends HttpServletRequestWrapper
+    {
+        private PortletRequest portletRequest;
+        
+        public PortletRequestParametersWrapper(HttpServletRequest request, PortletRequest portletRequest)
+        {
+            super(request);
+            this.portletRequest = portletRequest;
+        }
+
+        @Override
+        public String getParameter(String name)
+        {
+            return portletRequest.getParameter(name);
+        }
+
+        @Override
+        public Map<String, String[]> getParameterMap()
+        {
+            return portletRequest.getParameterMap();
+        }
+
+        @Override
+        public Enumeration<String> getParameterNames()
+        {
+            return portletRequest.getParameterNames();
+        }
+
+        @Override
+        public String[] getParameterValues(String name)
+        {
+            return portletRequest.getParameterValues(name);
+        }        
+    }
+    
+    private static final String INCLUDE_CONTEXT_PATH = "javax.servlet.include.context_path";
+    private static final String INCLUDE_PATH_INFO = "javax.servlet.include.path_info";
+    private static final String INCLUDE_QUERY_STRING = "javax.servlet.include.query_string";
+    private static final String INCLUDE_REQUEST_URI = "javax.servlet.include.request_uri";
+    private static final String INCLUDE_SERVLET_PATH = "javax.servlet.include.servlet_path";
+    private static final String FORWARD_CONTEXT_PATH = "javax.servlet.forward.context_path";
+    private static final String FORWARD_PATH_INFO = "javax.servlet.forward.path_info";
+    private static final String FORWARD_QUERY_STRING = "javax.servlet.forward.query_string";
+    private static final String FORWARD_REQUEST_URI = "javax.servlet.forward.request_uri";
+    private static final String FORWARD_SERVLET_PATH = "javax.servlet.forward.servlet_path";
+    
+    /**
+     * Cache for parsed dateHeader values.
+     */
+    protected static final HashMap<String,Long> dateHeaderParseCache = new HashMap<String,Long>();
+    
+    /**
+     * The set of SimpleDateFormat formats to use in getDateHeader().
+     *
+     * Notice that because SimpleDateFormat is not thread-safe, we can't
+     * declare formats[] as a static variable.
+     */
+    protected SimpleDateFormat dateHeaderFormats[] = 
+    {
+        new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
+        new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
+        new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US)
+    };
+    
+    private boolean included;
+    private boolean resetPathInfoAttributes;
+    private RequestDispatcherPathInfo methodPathInfo;
+    private RequestDispatcherPathInfo includedPathInfo;
+    private RequestDispatcherPathInfo forwardedPathInfo;
+    
+    private final ServletContext servletContext;
+    private final PortletRequest portletRequest;
+    private final ClientDataRequest clientDataRequest;
+    private final String lifecyclePhase;
+    private final boolean renderPhase;
+    private HttpSession session;
+    
+    public HttpServletPortletRequestWrapper(HttpServletRequest request, ServletContext servletContext, HttpSession session, PortletRequest portletRequest, RequestDispatcherPathInfo pathInfo, boolean included)
+    {
+        super(new PortletRequestParametersWrapper(request, portletRequest));
+        this.servletContext = servletContext;
+        this.session = session;
+        this.portletRequest = portletRequest;
+        lifecyclePhase = (String)portletRequest.getAttribute(PortletRequest.LIFECYCLE_PHASE);
+        clientDataRequest = PortletRequest.ACTION_PHASE.equals(lifecyclePhase) || PortletRequest.RESOURCE_PHASE.equals(lifecyclePhase) ? (ClientDataRequest)portletRequest : null;
+        renderPhase = PortletRequest.RENDER_PHASE.equals(lifecyclePhase);
+        setNewPathInfo(pathInfo, pathInfo, included);
+    }
+    
+    /**
+     * Try to parse the given date as a HTTP date. Borrowed and adapted from
+     * Tomcat FastHttpDateFormat
+     */
+    private long parseDateHeader(String value)
+    {
+        Long dateValue = null;
+        try
+        {
+            dateValue = dateHeaderParseCache.get(value);
+        }
+        catch (Exception e)
+        {
+        }
+        if (dateValue == null)
+        {
+            for (int i = 0; i < dateHeaderFormats.length; i++)
+            {
+                try
+                {
+                    Date date = dateHeaderFormats[i].parse(value);
+                    dateValue = new Long(date.getTime());
+                }
+                catch (ParseException e)
+                {
+                }
+            }
+            if (dateValue != null)
+            {
+                synchronized (dateHeaderParseCache)
+                {
+                    if (dateHeaderParseCache.size() > 1000)
+                    {
+                        dateHeaderParseCache.clear();
+                    }
+                    dateHeaderParseCache.put(value, dateValue);
+                }
+            }
+            else
+            {
+                throw new IllegalArgumentException(value);
+            }
+        }
+        return dateValue.longValue();
+    }
+    
+    private void resetPathInfoAttributes()
+    {
+        if (includedPathInfo == null || includedPathInfo.isNamedRequestDispatcher())
+        {
+            removeAttribute(INCLUDE_CONTEXT_PATH);
+            removeAttribute(INCLUDE_PATH_INFO);
+            removeAttribute(INCLUDE_QUERY_STRING);
+            removeAttribute(INCLUDE_REQUEST_URI);
+            removeAttribute(INCLUDE_SERVLET_PATH);
+        }
+        if (forwardedPathInfo == null || forwardedPathInfo.isNamedRequestDispatcher())
+        {
+            removeAttribute(FORWARD_CONTEXT_PATH);
+            removeAttribute(FORWARD_PATH_INFO);
+            removeAttribute(FORWARD_QUERY_STRING);
+            removeAttribute(FORWARD_REQUEST_URI);
+            removeAttribute(FORWARD_SERVLET_PATH);
+        }
+        if (includedPathInfo != null && !includedPathInfo.isNamedRequestDispatcher())
+        {
+            setAttribute(INCLUDE_CONTEXT_PATH, getContextPath());
+            setAttribute(INCLUDE_PATH_INFO, includedPathInfo.getPathInfo());
+            setAttribute(INCLUDE_QUERY_STRING, includedPathInfo.getQueryString());
+            setAttribute(INCLUDE_REQUEST_URI, includedPathInfo.getRequestURI());
+            setAttribute(INCLUDE_SERVLET_PATH, includedPathInfo.getServletPath());
+        }
+        if (forwardedPathInfo != null && !forwardedPathInfo.isNamedRequestDispatcher())
+        {
+            setAttribute(FORWARD_CONTEXT_PATH, getContextPath());
+            setAttribute(FORWARD_PATH_INFO, forwardedPathInfo.getPathInfo());
+            setAttribute(FORWARD_QUERY_STRING, forwardedPathInfo.getQueryString());
+            setAttribute(FORWARD_REQUEST_URI, forwardedPathInfo.getRequestURI());
+            setAttribute(FORWARD_SERVLET_PATH, forwardedPathInfo.getServletPath());
+        }
+        resetPathInfoAttributes = false;
+    }
+    
+    public boolean isForwardingPossible()
+    {
+        return !renderPhase;
+    }
+
+    public boolean isIncluded()
+    {
+        return included;
+    }
+    
+    public void setNewPathInfo(RequestDispatcherPathInfo methodPathInfo, RequestDispatcherPathInfo attributesPathInfo, boolean included)
+    {
+        this.methodPathInfo = methodPathInfo;
+        if (included)
+        {
+            includedPathInfo = attributesPathInfo;
+        }
+        else
+        {
+            forwardedPathInfo = attributesPathInfo;
+        }
+        this.included = included;
+        resetPathInfoAttributes = true;
+    }
+    
+    public void restorePathInfo(RequestDispatcherPathInfo methodPathInfo, RequestDispatcherPathInfo includedPathInfo, RequestDispatcherPathInfo forwardedPathInfo, boolean included)
+    {
+        this.methodPathInfo = methodPathInfo;
+        this.forwardedPathInfo = forwardedPathInfo;
+        this.includedPathInfo = includedPathInfo;
+        this.included = included;
+    }
+    
+    public RequestDispatcherPathInfo getMethodPathInfo()
+    {
+        return methodPathInfo;
+    }
+    
+    public RequestDispatcherPathInfo getIncludedPathInfo()
+    {
+        return includedPathInfo;
+    }
+    
+    public RequestDispatcherPathInfo getForwardedPathInfo()
+    {
+        return forwardedPathInfo;
+    }
+    
+    @Override
+    public String getAuthType()
+    {
+        return portletRequest.getAuthType();
+    }
+
+    @Override
+    public Cookie[] getCookies()
+    {
+        return portletRequest.getCookies();
+    }
+
+    @Override
+    public long getDateHeader(String name)
+    {
+        String value = portletRequest.getProperty(name);
+        if (value == null)
+        { 
+            return (-1L);
+        }
+        // Attempt to convert the date header in a variety of formats
+        return parseDateHeader(value);
+    }
+
+    @Override
+    public String getHeader(String name)
+    {
+        return portletRequest.getProperty(name);
+    }
+
+    @Override
+    public Enumeration<String> getHeaderNames()
+    {
+        return portletRequest.getPropertyNames();
+    }
+
+    @Override
+    public Enumeration<String> getHeaders(String name)
+    {
+        return portletRequest.getProperties(name);
+    }
+
+    @Override
+    public int getIntHeader(String name)
+    {
+        String property = portletRequest.getProperty(name);
+        if (property == null)
+        {
+            return -1;
+        }
+        else
+        {
+            return Integer.parseInt(property);
+        }
+    }
+
+    @Override
+    public String getMethod()
+    {
+        return renderPhase ? "GET" : super.getMethod();
+    }
+
+    @Override
+    public String getPathInfo()
+    {
+        return methodPathInfo.getPathInfo();
+    }
+
+    @Override
+    public String getPathTranslated()
+    {
+        return getPathInfo() != null ? servletContext.getRealPath(getPathInfo()) : null;
+    }
+
+    @Override
+    public String getQueryString()
+    {
+        return methodPathInfo.getQueryString();
+    }
+
+    @Override
+    public String getRemoteUser()
+    {
+        return portletRequest.getRemoteUser();
+    }
+
+    @Override
+    public String getRequestedSessionId()
+    {
+        return portletRequest.getRequestedSessionId();
+    }
+
+    @Override
+    public String getRequestURI()
+    {
+        return methodPathInfo.getRequestURI();
+    }
+
+    @Override
+    public StringBuffer getRequestURL()
+    {
+        return null;
+    }
+
+    @Override
+    public String getServletPath()
+    {
+        return methodPathInfo.getServletPath();
+    }
+
+    @Override
+    public HttpSession getSession()
+    {
+        return session !=  null ? session : super.getSession();
+    }
+
+    @Override
+    public HttpSession getSession(boolean create)
+    {
+        return session != null ? session : super.getSession(create);
+    }
+
+    @Override
+    public Principal getUserPrincipal()
+    {
+        return portletRequest.getUserPrincipal();
+    }
+
+    @Override
+    public boolean isRequestedSessionIdValid()
+    {
+        return portletRequest.isRequestedSessionIdValid();
+    }
+
+    @Override
+    public boolean isUserInRole(String role)
+    {
+        return portletRequest.isUserInRole(role);
+    }
+
+    @Override
+    public Object getAttribute(String name)
+    {
+        if (resetPathInfoAttributes)
+        {
+            resetPathInfoAttributes();
+        }
+        return portletRequest.getAttribute(name);
+    }
+
+    @Override
+    public Enumeration<String> getAttributeNames()
+    {
+        if (resetPathInfoAttributes)
+        {
+            resetPathInfoAttributes();
+        }
+        return portletRequest.getAttributeNames();
+    }
+
+    @Override
+    public String getCharacterEncoding()
+    {
+        return clientDataRequest != null ? clientDataRequest.getCharacterEncoding() : null;
+    }
+
+    @Override
+    public int getContentLength()
+    {
+        return clientDataRequest != null ? clientDataRequest.getContentLength() : 0;
+    }
+
+    @Override
+    public String getContentType()
+    {
+        return clientDataRequest != null ? clientDataRequest.getContentType() : null;
+    }
+
+    @Override
+    public ServletInputStream getInputStream() throws IOException
+    {
+        return clientDataRequest != null ? (ServletInputStream)clientDataRequest.getPortletInputStream() : null;
+    }
+
+    @Override
+    public String getLocalAddr()
+    {
+        return null;
+    }
+
+    @Override
+    public Locale getLocale()
+    {
+        return portletRequest.getLocale();
+    }
+
+    @Override
+    public Enumeration<Locale> getLocales()
+    {
+        return portletRequest.getLocales();
+    }
+
+    @Override
+    public String getLocalName()
+    {
+        return null;
+    }
+
+    @Override
+    public int getLocalPort()
+    {
+        return 0;
+    }
+
+    @Override
+    public String getProtocol()
+    {
+        return "HTTP/1.1";
+    }
+
+    @Override
+    public BufferedReader getReader() throws IOException
+    {
+        return clientDataRequest != null ? clientDataRequest.getReader() : null;
+    }
+
+    @Override
+    public String getRealPath(String path)
+    {
+        return null;
+    }
+
+    @Override
+    public String getRemoteAddr()
+    {
+        return null;
+    }
+
+    @Override
+    public String getRemoteHost()
+    {
+        return null;
+    }
+
+    @Override
+    public int getRemotePort()
+    {
+        return 0;
+    }
+
+    @Override
+    public RequestDispatcher getRequestDispatcher(String path)
+    {
+        if (path != null)
+        {
+            RequestDispatcher dispatcher = super.getRequestDispatcher(path);
+            if (dispatcher != null)
+            {
+                if (!path.startsWith("/"))
+                {
+                    String servletPath = !included ? forwardedPathInfo.getServletPath() : getServletPath();
+                    if (servletPath != null)
+                    {
+                        path = servletPath + path;
+                    }
+                    else
+                    {
+                        // Don't know what to do here: cannot determine needed servletPath prefix which should
+                        // be present to build a correct RequestDispatcherPathInfo
+                    }
+                }
+                PortletRequestContext requestContext = (PortletRequestContext)portletRequest.getAttribute(Constants.REQUEST_CONTEXT);
+                return new PortletRequestDispatcherImpl(dispatcher, requestContext.getPortletConfig().getPortletContext().getPathInfo(path));
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public String getScheme()
+    {
+        return portletRequest.getScheme();
+    }
+
+    @Override
+    public String getServerName()
+    {
+        return portletRequest.getServerName();
+    }
+
+    @Override
+    public int getServerPort()
+    {
+        return portletRequest.getServerPort();
+    }
+
+    @Override
+    public boolean isSecure()
+    {
+        return portletRequest.isSecure();
+    }
+
+    @Override
+    public void removeAttribute(String name)
+    {
+        portletRequest.removeAttribute(name);
+    }
+
+    @Override
+    public void setAttribute(String name, Object o)
+    {
+        portletRequest.setAttribute(name, o);
+    }
+
+    @Override
+    public void setCharacterEncoding(String enc) throws UnsupportedEncodingException
+    {
+        if (clientDataRequest != null)
+        {
+            clientDataRequest.setCharacterEncoding(enc);
+        }
+    }    
+}

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/HttpServletPortletRequestWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/HttpServletPortletRequestWrapper.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/HttpServletPortletRequestWrapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/HttpServletPortletResponseWrapper.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/HttpServletPortletResponseWrapper.java?rev=750954&view=auto
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/HttpServletPortletResponseWrapper.java (added)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/HttpServletPortletResponseWrapper.java Fri Mar  6 16:11:51 2009
@@ -0,0 +1,312 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.pluto.internal.impl;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.portlet.ActionResponse;
+import javax.portlet.MimeResponse;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.ResourceResponse;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+import org.apache.pluto.util.DummyPrintWriter;
+import org.apache.pluto.util.DummyServletOutputStream;
+
+/**
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id$
+ */
+public class HttpServletPortletResponseWrapper extends HttpServletResponseWrapper
+{
+    private final boolean forwarded;
+    private final PortletResponse portletResponse;
+    private final MimeResponse mimeResponse;
+    private final String lifecyclePhase;
+    private boolean included;
+    
+    public HttpServletPortletResponseWrapper(HttpServletResponse response, PortletRequest portletRequest, PortletResponse portletResponse, boolean included)
+    {
+        super(response);
+        this.portletResponse = portletResponse;
+        this.lifecyclePhase = (String)portletRequest.getAttribute(PortletRequest.LIFECYCLE_PHASE);
+        this.mimeResponse = PortletRequest.RENDER_PHASE.equals(lifecyclePhase) || PortletRequest.RESOURCE_PHASE.equals(lifecyclePhase) ? (MimeResponse)portletResponse : null;
+        this.forwarded = !included;
+        this.included = included;
+    }
+    
+    public void setIncluded(boolean included)
+    {
+        this.included = included;
+    }
+    
+    @Override
+    public void addCookie(Cookie cookie)
+    {
+        if (forwarded && !included)
+        {
+            portletResponse.addProperty(cookie);
+        }
+    }
+
+    @Override
+    public void addDateHeader(String name, long date)
+    {
+        if (forwarded && !included && mimeResponse != null)
+        {
+            mimeResponse.addProperty(name, Long.toString(date));
+        }
+    }
+
+    @Override
+    public void addHeader(String name, String value)
+    {
+        if (forwarded && !included && mimeResponse != null)
+        {
+            mimeResponse.addProperty(name, value);
+        }
+    }
+
+    @Override
+    public void addIntHeader(String name, int value)
+    {
+        if (forwarded && !included && mimeResponse != null)
+        {
+            mimeResponse.addProperty(name, Integer.toString(value));
+        }
+    }
+
+    @Override
+    public boolean containsHeader(String name)
+    {
+        return false;
+    }
+
+    @Override
+    public String encodeRedirectUrl(String url)
+    {
+        return null;
+    }
+
+    @Override
+    public String encodeRedirectURL(String url)
+    {
+        return null;
+    }
+
+    @Override
+    public String encodeUrl(String url)
+    {
+        return encodeURL(url);
+    }
+
+    @Override
+    public String encodeURL(String url)
+    {
+        if (url != null && url.indexOf("://") == -1 && !url.startsWith("/"))
+        {
+            // The Portlet Spec only allows URL encoding for absolute or full path URIs
+            // Letting this pass through thus would lead to an IllegalArgumentException been thrown.
+
+            // TODO: figure out how (if not impossible) this can be (pre)fixed properly
+            return url;
+        }
+        return portletResponse.encodeURL(url);
+    }
+
+    @Override
+    public void sendError(int sc, String msg) throws IOException
+    {
+    }
+
+    @Override
+    public void sendError(int sc) throws IOException
+    {
+    }
+
+    @Override
+    public void sendRedirect(String location) throws IOException
+    {
+        if (forwarded && !included && PortletRequest.ACTION_PHASE.equals(lifecyclePhase))
+        {
+            ((ActionResponse)portletResponse).sendRedirect(location);
+        }
+    }
+
+    @Override
+    public void setDateHeader(String name, long date)
+    {
+        if (forwarded && !included && mimeResponse != null)
+        {
+            mimeResponse.setProperty(name, Long.toString(date));
+        }
+    }
+
+    @Override
+    public void setHeader(String name, String value)
+    {
+        if (forwarded && !included && mimeResponse != null)
+        {
+            mimeResponse.setProperty(name, value);
+        }
+    }
+
+    @Override
+    public void setIntHeader(String name, int value)
+    {
+        if (forwarded && !included && mimeResponse != null)
+        {
+            mimeResponse.setProperty(name, Integer.toString(value));
+        }
+    }
+
+    @Override
+    public void setStatus(int sc, String sm)
+    {
+        setStatus(sc);
+    }
+
+    @Override
+    public void setStatus(int sc)
+    {
+        if (forwarded && !included && PortletRequest.RESOURCE_PHASE.equals(lifecyclePhase))
+        {
+            mimeResponse.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer.toString(sc));
+        }
+    }
+
+    @Override
+    public void flushBuffer() throws IOException
+    {
+        if (mimeResponse != null)
+        {
+            mimeResponse.flushBuffer();
+        }            
+    }
+
+    @Override
+    public int getBufferSize()
+    {
+        return mimeResponse != null ? mimeResponse.getBufferSize() : 0;
+    }
+
+    @Override
+    public String getCharacterEncoding()
+    {
+        return mimeResponse != null ? mimeResponse.getCharacterEncoding() : null;
+    }
+
+    @Override
+    public String getContentType()
+    {
+        return mimeResponse != null ? mimeResponse.getContentType() : null;
+    }
+
+    @Override
+    public Locale getLocale()
+    {
+        return mimeResponse != null ? mimeResponse.getLocale() : null;
+    }
+
+    @Override
+    public ServletOutputStream getOutputStream() throws IOException
+    {
+        return mimeResponse != null ? (ServletOutputStream)mimeResponse.getPortletOutputStream() : DummyServletOutputStream.getInstance();
+    }
+
+    @Override
+    public PrintWriter getWriter() throws IOException
+    {
+        return mimeResponse != null ? mimeResponse.getWriter() : DummyPrintWriter.getInstance();
+    }
+
+    @Override
+    public boolean isCommitted()
+    {
+        return mimeResponse != null ? mimeResponse.isCommitted() : forwarded ? false : true;
+    }
+
+    @Override
+    public void reset()
+    {
+        if (mimeResponse != null)
+        {
+            mimeResponse.reset();
+        }
+    }
+
+    @Override
+    public void resetBuffer()
+    {
+        if (mimeResponse != null)
+        {
+            mimeResponse.resetBuffer();
+        }
+    }
+
+    @Override
+    public void setBufferSize(int size)
+    {
+        if (mimeResponse != null)
+        {
+            mimeResponse.setBufferSize(size);
+        }
+    }
+
+    @Override
+    public void setCharacterEncoding(String charset)
+    {
+        if (forwarded && !included && PortletRequest.RESOURCE_PHASE.equals(lifecyclePhase))
+        {
+            ((ResourceResponse)portletResponse).setCharacterEncoding(charset);
+        }
+    }
+
+    @Override
+    public void setContentLength(int len)
+    {
+        if (forwarded && !included && PortletRequest.RESOURCE_PHASE.equals(lifecyclePhase))
+        {
+            ((ResourceResponse)portletResponse).setContentLength(len);
+        }
+    }
+
+    @Override
+    public void setContentType(String type)
+    {
+        if (forwarded && !included && mimeResponse != null)
+        {
+            mimeResponse.setContentType(type);
+        }
+    }
+
+    @Override
+    public void setLocale(Locale loc)
+    {
+        if (forwarded && !included && PortletRequest.RESOURCE_PHASE.equals(lifecyclePhase))
+        {
+            ((ResourceResponse)portletResponse).setLocale(loc);
+        }
+    }    
+}

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/HttpServletPortletResponseWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/HttpServletPortletResponseWrapper.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/HttpServletPortletResponseWrapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/MimeResponseImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/MimeResponseImpl.java?rev=750954&r1=750953&r2=750954&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/MimeResponseImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/MimeResponseImpl.java Fri Mar  6 16:11:51 2009
@@ -20,372 +20,187 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintWriter;
-import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Locale;
 
 import javax.portlet.CacheControl;
 import javax.portlet.MimeResponse;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pluto.PortletContainer;
-import org.apache.pluto.PortletEntity;
-import org.apache.pluto.PortletWindow;
+import javax.portlet.PortletURL;
+import javax.portlet.ResourceURL;
+
 import org.apache.pluto.om.portlet.PortletDefinition;
 import org.apache.pluto.om.portlet.Supports;
-import org.apache.pluto.util.StringManager;
-
-public class MimeResponseImpl extends PortletResponseImpl implements
-		MimeResponse {
-	
-	/** Logger. */
-	private static final Log LOG = LogFactory.getLog(MimeResponseImpl.class);
-	
-	private static final StringManager EXCEPTIONS = StringManager.getManager(
-    		MimeResponseImpl.class.getPackage().getName());
-	
-	private class CacheControlImpl implements CacheControl {
-
-		private String eTag;
-
-		private int expirationTime;
-
-		private boolean publicScope;
-
-		private boolean cachedContent;
-
-		public CacheControlImpl() {
-			super();
-		}
-
-		public boolean useCachedContent() {
-			return this.cachedContent;
-		}
+import org.apache.pluto.spi.optional.PortletMimeResponseContext;
 
-		public String getETag() {
-			return this.eTag;
-		}
-
-		public int getExpirationTime() {
-			return this.expirationTime;
-		}
-
-		public boolean isPublicScope() {
-			return this.publicScope;
-		}
-
-		public void setETag(String eTag) {
-			this.eTag = eTag;
-		}
-
-		public void setExpirationTime(int expirationTime) {
-			this.expirationTime = expirationTime;
-			MimeResponseImpl.super.setProperty(EXPIRATION_CACHE, String
-					.valueOf(expirationTime));
-		}
-
-		public void setPublicScope(boolean publicScope) {
-			this.publicScope = publicScope;
-			MimeResponseImpl.super.setProperty(PUBLIC_SCOPE,
-					publicScope ? PUBLIC_SCOPE : PRIVATE_SCOPE);
-		}
-
-		public void setUseCachedContent(boolean cachedContent) {
-			this.cachedContent = cachedContent;
-			MimeResponseImpl.super.setProperty(USE_CACHED_CONTENT,
-					cachedContent ? Boolean.TRUE.toString() : null);
-		}
+public class MimeResponseImpl extends PortletResponseImpl implements MimeResponse
+{
+    /** Response content types. */
+    private ArrayList<String> responseContentTypes;
+    
+    private boolean usingWriter;
+    private boolean usingStream;
+
+    private PortletMimeResponseContext responseContext;
+    
+	public MimeResponseImpl(PortletMimeResponseContext responseContext)
+	{
+		super(responseContext);
+		this.responseContext = responseContext;
+		PortletDefinition portletDefinition = getPortletWindow().getPortletEntity().getPortletDefinition();
+		getCacheControl().setExpirationTime(portletDefinition.getExpirationCache());
+		getCacheControl().setPublicScope(PUBLIC_SCOPE.equals(portletDefinition.getCacheScope()));
+	}
+	
+    protected List<String> getResponseContentTypes() 
+    {
+        if (responseContentTypes == null) 
+        {
+            responseContentTypes = new ArrayList<String>();
+            PortletDefinition dd = getPortletWindow().getPortletEntity().getPortletDefinition();
+            for (Supports sup : dd.getSupports())
+            {
+                responseContentTypes.add(sup.getMimeType());
+            }
+            if (responseContentTypes.isEmpty()) 
+            {
+                responseContentTypes.add("text/html");
+            }
+        }
+        return responseContentTypes;
+    }
+    
+    public PortletURL createActionURL()
+    {
+        return new PortletURLImpl(responseContext, true, false);
+    }
+    
+    public PortletURL createRenderURL()
+    {
+        return new PortletURLImpl(responseContext, false, false);
+    }
 
-	}
 
-	private CacheControl cacheControl;
+    public ResourceURL createResourceURL()
+    {
+        return new PortletURLImpl(responseContext, false, true);
+    }
+    
+    public void flushBuffer() throws IOException
+    {
+        responseContext.flushBuffer();
+    }
 
-	public MimeResponseImpl(PortletContainer container,
-            PortletWindow portletWindow,
-            HttpServletRequest servletRequest,
-            HttpServletResponse servletResponse) {
-		
-		super(container, portletWindow, servletRequest,
-				servletResponse);
-		this.cacheControl = new CacheControlImpl();
-		PortletEntity portletEntity = portletWindow.getPortletEntity();
-		PortletDefinition portletDefinition = portletEntity.getPortletDefinition();
-        this.setProperty(EXPIRATION_CACHE, String.valueOf(portletDefinition.getExpirationCache()));
-        this.setProperty(CACHE_SCOPE, portletDefinition.getCacheScope());
-	}
-	
-	@Override
-    public void flushBuffer() throws IOException {
-        getHttpServletResponse().flushBuffer();
+    public int getBufferSize()
+    {
+        return responseContext.getBufferSize();
     }
     
 	public CacheControl getCacheControl() {
-		return this.cacheControl;
+		return responseContext.getCacheControl();
 	}
 	
-	@Override
-	public void setProperty(String name, String value) {
-		if (USE_CACHED_CONTENT.equals(name)) {
-			this.cacheControl.setUseCachedContent(value != null);
-		} else if (EXPIRATION_CACHE.equals(name)) {
-			int expirationTime;
-			try {
-				expirationTime = Integer.parseInt(value);
-			} catch (NumberFormatException e) {
-				expirationTime = 0;
-			}
-			this.cacheControl.setExpirationTime(expirationTime);
-		} else if (ETAG.equals(name)) {
-			this.cacheControl.setETag(value);
-		} else if (CACHE_SCOPE.equals(name)) {
-			this.cacheControl.setPublicScope(PUBLIC_SCOPE.equals(value));
-		} else {
-			super.setProperty(name, value);
-		}
-	}
-	
-	@Override
-	public String getCharacterEncoding() {
-        return getHttpServletResponse().getCharacterEncoding();
+    public String getCharacterEncoding()
+    {
+        return responseContext.getCharacterEncoding();
     }
-	
-	@Override
-	public Locale getLocale() {
-        return getHttpServletResponse().getLocale();
-    }
-	
-    /**
-     * @see PortletResponseImpl#getOutputStream()
-     * @see #getWriter()
-     */
-	public OutputStream getPortletOutputStream() throws IOException {
-		if (getContentType() == null) {
-			setContentType("text/html");
-//            String message = EXCEPTIONS.getString("error.contenttype.null");
-//            if (LOG.isWarnEnabled()) {
-//            	LOG.warn("Current content type is not set.");
-//            }
-//            throw new IllegalStateException(message);
-        }
-        return super.getOutputStream();
-	}
-	
-	
-	public String getContentType(){
-		return super.getContentType();
-	}
-	public void setContentType(String arg0){
-		super.setContentType(arg0);
-	}
-	/**
-     * @see PortletResponseImpl#getWriter()
-     * @see #getPortletOutputStream()
-     */
-	@Override
-    public PrintWriter getWriter() throws IOException {
-        if (getContentType() == null) {
-        	setContentType("text/html");
-        }
-        return super.getWriter();
-    }
-    
-	@Override
-    public boolean isCommitted() {
-        return getHttpServletResponse().isCommitted();
+
+    public String getContentType()
+    {
+        return responseContext.getContentType();
     }
     
-	@Override
-    public void reset() {
-        getHttpServletResponse().reset();
+    public Locale getLocale()
+    {
+        return responseContext.getLocale();
     }
-    
-	@Override
-    public void resetBuffer() {
-        getHttpServletResponse().resetBuffer();
+
+    public OutputStream getPortletOutputStream()
+    throws IllegalStateException, IOException
+    {
+        if (usingWriter)
+        {
+            throw new IllegalStateException("getPortletOutputStream can't be used after getWriter was invoked.");
+        }
+        if (getContentType() == null)
+        {
+            setContentType(getResponseContentTypes().get(0));
+        }
+        usingStream = true;
+        return responseContext.getOutputStream();
     }
     
-	public int getBufferSize(){
-		return super.getBufferSize();
-	}
-	
-	@Override
-    public void setBufferSize(int size) {
-    	getHttpServletResponse().setBufferSize(size);
+    public PrintWriter getWriter()
+    throws IllegalStateException, IOException
+    {
+        if (usingStream)
+        {
+            throw new IllegalStateException("getWriter can't be used after getOutputStream was invoked.");
+        }
+        if (getContentType() == null)
+        {
+            setContentType(getResponseContentTypes().get(0));
+        }
+        usingWriter = true;
+        return responseContext.getWriter();
     }
-    
-    // access to a limited set of HttpServletResponse methods ------------------
-	
-	@Override
-	public void addDateHeader(String arg0, long arg1) {
-		if (super.isIncluded()){
-			//no operation
-		}
-		else if (super.isForwarded()){
-			super.addProperty(arg0, Long.toString(arg1));
-		}
-		else
-			super.addDateHeader(arg0, arg1);
-	}
-	
-	@Override
-	public void addHeader(String arg0, String arg1) {
-		if (super.isIncluded()){
-			//no operation
-		}
-		else if (super.isForwarded()){
-			super.addProperty(arg0, arg1);
-		}
-		else
-			super.addHeader(arg0, arg1);
-	}
-	
-	@Override
-	public void addIntHeader(String arg0, int arg1) {
-		if (super.isIncluded()){
-			//no operation
-		}
-		else if (super.isForwarded()){
-			super.addProperty(arg0, Integer.toString(arg1));
-		}
-		else
-			super.addIntHeader(arg0, arg1);
-	}
-	
-	@Override
-	public ServletOutputStream getOutputStream() throws IllegalStateException, IOException {
-		if (super.isIncluded() || super.isForwarded()){
-			return (ServletOutputStream)getPortletOutputStream();
-		}
-		else
-			return super.getOutputStream();
-	}
-
-	@Override
-	public void sendRedirect(String arg0) throws IOException {
-		if (super.isIncluded() || super.isForwarded()){
-			// no operation
-		}
-		else
-			super.sendRedirect(arg0);
-	}
-
-	@Override
-	public void setDateHeader(String arg0, long arg1) {
-		if (super.isIncluded()){
-			//no operation
-		}
-		else if (super.isForwarded()){
-			super.setProperty(arg0, Long.toString(arg1));
-		}
-		else
-			super.setDateHeader(arg0, arg1);
-	}
 
-	@Override
-	public void setHeader(String arg0, String arg1) {
-		if (super.isIncluded()){
-			//no operation
-		}
-		else if (super.isForwarded()){
-			super.setProperty(arg0, arg1);
-		}
-		else
-			super.setHeader(arg0, arg1);
-	}
+    public boolean isCommitted()
+    {
+        return responseContext.isCommitted();
+    }
 
-	@Override
-	public void setIntHeader(String arg0, int arg1) {
-		if (super.isIncluded()){
-			//no operation
-		}
-		else if (super.isForwarded()){
-			super.setProperty(arg0, Integer.toString(arg1));
-		}
-		else
-			super.setIntHeader(arg0, arg1);
-	}
+    public void reset()
+    {
+        responseContext.reset();
+    }
 
-	@Override
-	public void setStatus(int arg0, String arg1) {
-		if (super.isIncluded()){
-			//no operation
-		}
-		else if (super.isForwarded()){
-			super.setProperty(arg1, Integer.toString(arg0));
-		}
-		else
-			super.setStatus(arg0, arg1);
-	}
+    public void resetBuffer()
+    {
+        responseContext.resetBuffer();
+    }
 
-	@Override
-	public void setStatus(int arg0) {
-		if (super.isIncluded()){
-			//no operation
-		}
-		else if (super.isForwarded()){
-			super.setProperty("STATUS", Integer.toString(arg0));
-		}
-		else
-		super.setStatus(arg0);
-	}
+    public void setBufferSize(int size)
+    {
+        responseContext.setBufferSize(size);
+    }
     
-	public javax.portlet.PortletURL createRenderURL(){
-		return super.createRenderURL();
-	}
-	public javax.portlet.PortletURL createActionURL(){
-		return super.createActionURL();
-	}
-	public javax.portlet.ResourceURL createResourceURL(){
-		return super.createResourceURL();
-	}
-	
-    // Private Methods ---------------------------------------------------------
+    public void setContentType(String contentType)
+    {
+        responseContext.setContentType(contentType);
+    }
     
-    /**
-     * Checks if the specified content type is valid (supported by the portlet).
-     * The specified content type should be a tripped mime type without any
-     * character encoding suffix.
-     * @param contentType  the content type to check.
-     * @return true if the content type is valid, false otherwise.
-     */
-    protected boolean isValidContentType(String contentType) {
-    	boolean valid = false;
-    	
-        PortletDefinition portletDD = getPortletWindow().getPortletEntity()
-        		.getPortletDefinition();
-        for (Iterator it = portletDD.getSupports().iterator();
-        		!valid && it.hasNext(); ) {
-            
-        	Supports supportsDD = (Supports) it.next();
-            String supportedType = supportsDD.getMimeType();
-            
-            // Content type is supported by an exact match.
-            if (supportedType.equals(contentType)) {
-            	valid = true;
-            }
-            // The supported type contains a wildcard.
-            else if (supportedType.indexOf("*") >= 0) {
-            	
-                int index = supportedType.indexOf("/");
-                String supportedPrefix = supportedType.substring(0, index);
-                String supportedSuffix = supportedType.substring(index + 1);
-                
-                index = contentType.indexOf("/");
-                String typePrefix = contentType.substring(0, index);
-                String typeSuffix = contentType.substring(index + 1);
-                
-                // Check if the prefixes match AND the suffixes match.
-                if (supportedPrefix.equals("*") || supportedPrefix.equals(typePrefix)) {
-                    if (supportedSuffix.equals("*") || supportedSuffix.equals(typeSuffix)) {
-                        valid = true;
-                    }
-                }
+    @Override
+    public void setProperty(String name, String value)
+    {
+        if (USE_CACHED_CONTENT.equals(name))
+        {
+            getCacheControl().setUseCachedContent(value != null);
+        } 
+        else if (EXPIRATION_CACHE.equals(name))
+        {
+            int expirationTime;
+            try 
+            {
+                expirationTime = Integer.parseInt(value);
+            } 
+            catch (NumberFormatException e)
+            {
+                expirationTime = 0;
             }
+            getCacheControl().setExpirationTime(expirationTime);
+        } 
+        else if (ETAG.equals(name)) 
+        {
+            getCacheControl().setETag(value);
+        } 
+        else if (CACHE_SCOPE.equals(name))
+        {
+            getCacheControl().setPublicScope(PUBLIC_SCOPE.equals(value));
+        } 
+        else 
+        {
+            super.setProperty(name, value);
         }
-        // Return the check result.
-        return valid;
     }
 }

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletConfigImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletConfigImpl.java?rev=750954&r1=750953&r2=750954&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletConfigImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletConfigImpl.java Fri Mar  6 16:11:51 2009
@@ -27,13 +27,13 @@
 import java.util.ResourceBundle;
 
 import javax.portlet.PortletConfig;
-import javax.portlet.PortletContext;
 import javax.xml.XMLConstants;
 import javax.xml.namespace.QName;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pluto.internal.InternalPortletConfig;
+import org.apache.pluto.internal.InternalPortletContext;
 import org.apache.pluto.om.portlet.ContainerRuntimeOption;
 import org.apache.pluto.om.portlet.EventDefinitionReference;
 import org.apache.pluto.om.portlet.InitParam;
@@ -47,7 +47,7 @@
     /**
      * The Portlet Application Context within which we exist.
      */
-    protected PortletContext portletContext;
+    protected InternalPortletContext portletContext;
 
     /**
      * The portlet descriptor.
@@ -60,8 +60,10 @@
     protected PortletApplicationDefinition portletApp;
 
     protected ResourceBundleFactory bundles;
+    
+    protected Map<String, String[]> containerRuntimeOptions;
 
-    public PortletConfigImpl(PortletContext portletContext,
+    public PortletConfigImpl(InternalPortletContext portletContext,
                              PortletDefinition portletDD,
                              PortletApplicationDefinition portletAppDD) {
         this.portletContext = portletContext;
@@ -73,7 +75,7 @@
         return portlet.getPortletName();
     }
 
-    public PortletContext getPortletContext() {
+    public InternalPortletContext getPortletContext() {
         return portletContext;
     }
 
@@ -185,64 +187,66 @@
 		return Collections.enumeration(locals);
 	}
 	
-	public Map<String, String[]> getApplicationRuntimeOptions() {
-		Map<String, String[]> resultMap = new HashMap<String, String[]>();
-		if (portletApp.getContainerRuntimeOptions() != null){
-			for (ContainerRuntimeOption option : portletApp.getContainerRuntimeOptions()) {
-				if (getSupportedContainerRuntimeOptions().contains(option.getName())){
-					List<String> values = option.getValues();
-					String [] tempValues = new String[values.size()];
-					for (int i=0;i<values.size();i++){
-						tempValues[i] = values.get(i);
-					}
-					resultMap.put(option.getName(),tempValues);
-				}
-			}
-		}
-		return resultMap;
-	}
-	
-	public Map<String, String[]> getPortletRuntimeOptions() {
-		Map<String, String[]> resultMap = new HashMap<String, String[]>();
-		if (portlet.getContainerRuntimeOptions() != null) {
-			for (ContainerRuntimeOption option : portlet.getContainerRuntimeOptions()) {
-				if (getSupportedContainerRuntimeOptions().contains(option.getName())){
-					List<String> values = option.getValues();
-					String [] tempValues = new String[values.size()];
-					for (int i=0;i<values.size();i++){
-						tempValues[i] = values.get(i);
-					}
-					resultMap.put(option.getName(),tempValues);
-				}
-			}
-		}
-		return resultMap;
-	}
-
-	public Map<String, String[]> getContainerRuntimeOptions() {
-		
-		Map<String,String[]> appRuntimeOptions = getApplicationRuntimeOptions();
-		Map<String,String[]> portletRuntimeOptions = getPortletRuntimeOptions();
-		
-		// merge these two, with portlet priority
-		Map<String, String[]> resultMap = new HashMap<String, String[]>();
-		
-		// first all entries in portletAppDD (without these in portletDD)
-		for (String option : appRuntimeOptions.keySet()) {
-			if (portletRuntimeOptions.containsKey(option))
-				resultMap.put(option, portletRuntimeOptions.get(option));
-			else
-				resultMap.put(option, appRuntimeOptions.get(option));
-		}
-		// and now the rest
-		if (portletRuntimeOptions != null){
-			for (String option : portletRuntimeOptions.keySet()) {
-				if (!appRuntimeOptions.containsKey(option))
-					resultMap.put(option, portletRuntimeOptions.get(option));
-			}
-		}
-		//return resultMap;
-		return null;
+	public Map<String, String[]> getContainerRuntimeOptions()
+	{
+	    synchronized(this)
+	    {
+	        if (containerRuntimeOptions == null)
+	        {
+	            containerRuntimeOptions = new HashMap<String, String[]>();
+	            if (portletApp.getContainerRuntimeOptions() != null)
+	            {
+	                for (ContainerRuntimeOption option : portletApp.getContainerRuntimeOptions())
+	                {
+	                    List<String> values = option.getValues();
+	                    String [] tempValues = new String[values.size()];
+	                    for (int i=0;i<values.size();i++)
+	                    {
+	                        tempValues[i] = values.get(i);
+	                    }
+	                    containerRuntimeOptions.put(option.getName(),tempValues);
+	                }
+	            }
+	            if (portlet.getContainerRuntimeOptions() != null)
+	            {
+	                for (ContainerRuntimeOption option : portlet.getContainerRuntimeOptions())
+	                {
+	                    List<String> values = option.getValues();
+	                    String [] tempValues = new String[values.size()];
+	                    for (int i=0;i<values.size();i++)
+	                    {
+	                        tempValues[i] = values.get(i);
+	                    }
+	                    containerRuntimeOptions.put(option.getName(),tempValues);
+	                }
+	            }
+	            for (Iterator<String> iter = containerRuntimeOptions.keySet().iterator(); iter.hasNext(); )
+	            {
+	                String key = iter.next();
+	                if (!getSupportedContainerRuntimeOptions().contains(key))
+	                {
+	                    iter.remove();
+	                }
+	            }
+	        }
+	    }
+	    
+        if (!containerRuntimeOptions.isEmpty())
+        {
+            Map<String, String[]> result = new HashMap<String, String[]>(containerRuntimeOptions.size());
+            for (Map.Entry<String,String[]> entry : containerRuntimeOptions.entrySet())
+            {
+                if (entry.getValue() != null)
+                {
+                    result.put(entry.getKey(), entry.getValue().clone());
+                }
+            }
+            return Collections.unmodifiableMap(result);
+        }
+        else
+        {
+            return Collections.emptyMap();
+        }
 	}
 	
     protected List<String> getSupportedContainerRuntimeOptions()

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletContextImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletContextImpl.java?rev=750954&r1=750953&r2=750954&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletContextImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletContextImpl.java Fri Mar  6 16:11:51 2009
@@ -19,10 +19,10 @@
 import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Enumeration;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 import javax.portlet.PortletContext;
@@ -33,8 +33,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pluto.internal.InternalPortletContext;
-import org.apache.pluto.om.portlet.ContainerRuntimeOption;
-import org.apache.pluto.om.portlet.PortletDefinition;
+import org.apache.pluto.internal.RequestDispatcherPathInfo;
 import org.apache.pluto.om.portlet.PortletApplicationDefinition;
 
 /**
@@ -55,14 +54,14 @@
     
     // Private Member Variables ------------------------------------------------
     
-    
-    /** Portlet */
-    protected PortletDefinition portlet = null;
-
     protected final PortletApplicationDefinition portletApp;
     protected final ServletContext servletContext;
     protected ClassLoader contextClassLoader;
 
+    protected List<String> exactServletMappingURLPatterns;
+    protected List<String> pathServletMappingURLPatterns;
+    protected List<String> extServletMappingURLPatterns;
+    protected boolean defaultServletMapping = false;
     
     // Constructor -------------------------------------------------------------
     
@@ -81,7 +80,7 @@
     private void init() {
         setContextClassLoader(Thread.currentThread().getContextClassLoader());
     }
-
+    
     public String getApplicationName() {
         return portletApp.getName();
     }
@@ -120,6 +119,106 @@
     public String getServerInfo() {
         return Environment.getServerInfo();
     }
+    
+    public RequestDispatcherPathInfo getPathInfo(String path)
+    {
+        String servletPath = null;
+        String pathInfo = null;
+        String queryString = null;
+        
+        int index = path.indexOf('?');
+        if (index != -1)
+        {
+            queryString = path.substring(index+1, path.length());
+            path = path.substring(0, index);
+        }
+        
+        synchronized (this)
+        {
+            if (exactServletMappingURLPatterns == null)
+            {
+                defaultServletMapping = false;
+                exactServletMappingURLPatterns = new ArrayList<String>();
+                pathServletMappingURLPatterns = new ArrayList<String>();
+                extServletMappingURLPatterns = new ArrayList<String>();
+                
+                for (String pat : portletApp.getServletMappingURLPatterns())
+                {                 
+                    if (pat.startsWith("/"))
+                    {
+                        if (pat.equals("/"))
+                        {
+                            defaultServletMapping = true;
+                        }
+                        else if (pat.endsWith("/*"))
+                        {
+                            pathServletMappingURLPatterns.add(pat.substring(0,-2));
+                        }
+                        else
+                        {
+                            exactServletMappingURLPatterns.add(pat);
+                        }
+                    }
+                    else if (pat.startsWith("*."))
+                    {
+                        extServletMappingURLPatterns.add(pat.substring(1));
+                    }
+                    else
+                    {
+                        exactServletMappingURLPatterns.add(pat);
+                    }
+                }
+            }
+        }
+        if (exactServletMappingURLPatterns.contains(path))
+        {
+            servletPath = path;
+            pathInfo = null;
+        }
+        else if ( path.charAt(0) == '/' && (index = path.lastIndexOf('/')) != -1)
+        {
+            if (path.length() == 1 && defaultServletMapping)
+            {
+                servletPath = path;
+                pathInfo = null;
+            }
+            else
+            {
+                String sub = path;
+                do
+                {
+                    sub = sub.substring(0, index);
+                    if (pathServletMappingURLPatterns.contains(sub))
+                    {
+                        servletPath = sub;
+                        pathInfo = path.substring(sub.length()+1);
+                        break;
+                    }
+                    index = sub.lastIndexOf('/');
+                }
+                while (index != -1);
+            }
+        }
+        if (servletPath == null)
+        {
+            ;            
+            if ((index = path.lastIndexOf('/')) != -1)
+            {
+                int ext = path.indexOf('.', index);
+                if (extServletMappingURLPatterns.contains(path.substring(index)))
+                {
+                    servletPath = path.substring(0, index);
+                    pathInfo = path.substring(index);
+                }
+            }
+        }
+        if (servletPath == null)
+        {
+            servletPath = path;            
+        }
+        
+        return new RequestDispatcherPathInfoImpl(getContextPath(),servletPath,pathInfo,queryString);
+    }
 
     public PortletRequestDispatcher getRequestDispatcher(String path) {
     	
@@ -143,8 +242,8 @@
             RequestDispatcher servletRequestDispatcher = servletContext
             		.getRequestDispatcher(path);
             if (servletRequestDispatcher != null) {
-            	portletRequestDispatcher = new PortletRequestDispatcherImpl(
-                		servletRequestDispatcher, path);
+
+            	portletRequestDispatcher = new PortletRequestDispatcherImpl(servletRequestDispatcher, getPathInfo(path));
             } else {
             	if (LOG.isInfoEnabled()) {
             		LOG.info("No matching request dispatcher found for: " + path);
@@ -274,70 +373,8 @@
         return portletApp;
     }
 
-
-	public Map<String, String[]> getApplicationRuntimeOptions() {
-		Map<String, String[]> resultMap = new HashMap<String, String[]>();
-		if (portletApp.getContainerRuntimeOptions() != null){
-			for (ContainerRuntimeOption option : portletApp.getContainerRuntimeOptions()) {
-				if (getSupportedContainerRuntimeOptions().contains(option.getName())){
-					List<String> values = option.getValues();
-					String [] tempValues = new String[values.size()];
-					for (int i=0;i<values.size();i++){
-						tempValues[i] = values.get(i);
-					}
-					resultMap.put(option.getName(),tempValues);
-				}
-			}
-		}
-		return resultMap;
-	}
-
-	public Map<String, String[]> getPortletRuntimeOptions() {
-		Map<String, String[]> resultMap = new HashMap<String, String[]>();
-		if (portlet.getContainerRuntimeOptions() != null) {
-			for (ContainerRuntimeOption option : portlet.getContainerRuntimeOptions()) {
-				if (this.getSupportedContainerRuntimeOptions().contains(option.getName())){
-					List<String> values = option.getValues();
-					String [] tempValues = new String[values.size()];
-					for (int i=0;i<values.size();i++){
-						tempValues[i] = values.get(i);
-					}
-					resultMap.put(option.getName(),tempValues);
-				}
-			}
-		}
-		return resultMap;
-	}
-
-
 	public Enumeration<String> getContainerRuntimeOptions() {
-		Map<String,String[]> appRuntimeOptions = getApplicationRuntimeOptions();
-		Map<String,String[]> portletRuntimeOptions = getPortletRuntimeOptions();
-		
-		// merge these two, with portlet priority
-		Map<String, String[]> resultMap = new HashMap<String, String[]>();
-		
-		// first all entries in portletAppDD (without these in portletDD)
-		for (String option : appRuntimeOptions.keySet()) {
-			if (portletRuntimeOptions.containsKey(option))
-				resultMap.put(option, portletRuntimeOptions.get(option));
-			else
-				resultMap.put(option, appRuntimeOptions.get(option));
-		}
-		// and now the rest
-		if (portletRuntimeOptions != null){
-			for (String option : portletRuntimeOptions.keySet()) {
-				if (!appRuntimeOptions.containsKey(option))
-					resultMap.put(option, portletRuntimeOptions.get(option));
-			}
-		}
-		//return resultMap;
-		return null;
-	}
-	
-	protected List<String> getSupportedContainerRuntimeOptions()
-	{
-	    return Configuration.getSupportedContainerRuntimeOptions();
+	    return Collections.enumeration(Configuration.getSupportedContainerRuntimeOptions());
 	}
 }
 

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletPreferencesImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletPreferencesImpl.java?rev=750954&r1=750953&r2=750954&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletPreferencesImpl.java (original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletPreferencesImpl.java Fri Mar  6 16:11:51 2009
@@ -24,18 +24,17 @@
 import java.util.Vector;
 
 import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
 import javax.portlet.PreferencesValidator;
 import javax.portlet.ReadOnlyException;
 import javax.portlet.ValidatorException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.pluto.Constants;
 import org.apache.pluto.PortletContainer;
 import org.apache.pluto.PortletContainerException;
 import org.apache.pluto.PortletWindow;
 import org.apache.pluto.internal.InternalPortletPreference;
-import org.apache.pluto.internal.InternalPortletRequest;
 import org.apache.pluto.om.portlet.PortletDefinition;
 import org.apache.pluto.spi.optional.PortletPreferencesService;
 import org.apache.pluto.util.StringManager;
@@ -63,7 +62,7 @@
 
     private PortletWindow window;
 
-    private InternalPortletRequest request;
+    private PortletRequest request;
     
     /**
      * Default portlet preferences retrieved from portlet.xml, and used for
@@ -77,10 +76,6 @@
      */
     private final Map<String, InternalPortletPreference> preferences = new HashMap<String, InternalPortletPreference>();
 
-    /** Current method used for managing these preferences. */
-    private Integer methodId;
-    
-    
     // Constructor -------------------------------------------------------------
     
     /**
@@ -88,15 +83,13 @@
      * @param container  the portlet container.
      * @param window  the internal portlet window.
      * @param request  the internal portlet request.
-     * @param methodId  the request method ID: render request or action request.
      */
     public PortletPreferencesImpl(PortletContainer container,
                                   PortletWindow window,
-                                  InternalPortletRequest request,
-                                  Integer methodId) {
+                                  PortletRequest request)
+    {
         this.window = window;
         this.request = request;
-        this.methodId = methodId;
         
         // Get the portlet preferences service from container.
         preferencesService = container.getOptionalContainerServices()
@@ -249,9 +242,9 @@
      * @throws IOException  if an error occurs with the persistence mechanism.
      */
     public void store() throws IOException, ValidatorException {
-        if (!Constants.METHOD_ACTION.equals(methodId)) {
+        if (PortletRequest.RENDER_PHASE.equals(request.getAttribute(PortletRequest.LIFECYCLE_PHASE))) {
             throw new IllegalStateException(
-                	"store is only allowed inside a processAction call.");
+                	"store is not allowed during RENDER phase.");
         }
         internalStore();
     }