You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2008/06/19 23:50:00 UTC

svn commit: r669711 [1/2] - in /myfaces/tomahawk/trunk/core/src/main: conf/META-INF/ java/org/apache/myfaces/webapp/filter/ java/org/apache/myfaces/webapp/filter/portlet/ java/org/apache/myfaces/webapp/filter/servlet/

Author: lu4242
Date: Thu Jun 19 14:49:59 2008
New Revision: 669711

URL: http://svn.apache.org/viewvc?rev=669711&view=rev
Log:
MYFACES-434 MyFaces's Portlet enhancement Add multipart content support, (fileUpload for portlets pending)

Added:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilterConfig.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/PortletExternalContextWrapper.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestHeaderMap.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestHeaderValuesMap.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestMap.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestParameterMap.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestParameterValuesMap.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/SessionMap.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/AbstractAttributeMap.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/CookieMap.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestHeaderMap.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestHeaderValuesMap.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestMap.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestParameterMap.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestParameterValuesMap.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/ServletExternalContextWrapper.java   (with props)
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/SessionMap.java   (with props)
Removed:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExternalContextWrapper.java
Modified:
    myfaces/tomahawk/trunk/core/src/main/conf/META-INF/faces-config-base.xml
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextWrapper.java

Modified: myfaces/tomahawk/trunk/core/src/main/conf/META-INF/faces-config-base.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/conf/META-INF/faces-config-base.xml?rev=669711&r1=669710&r2=669711&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/conf/META-INF/faces-config-base.xml (original)
+++ myfaces/tomahawk/trunk/core/src/main/conf/META-INF/faces-config-base.xml Thu Jun 19 14:49:59 2008
@@ -26,18 +26,18 @@
 <faces-config xmlns="http://java.sun.com/JSF/Configuration">
 
   <lifecycle>
-      <!-- 
+
       <phase-listener>org.apache.myfaces.webapp.filter.ServeResourcePhaseListener</phase-listener>
-       -->
+
       <phase-listener>org.apache.myfaces.renderkit.html.util.ExtensionsPhaseListener</phase-listener>
       <!-- This PhaseListener is only necessary if the autoscroll feature is used -->
       <phase-listener>org.apache.myfaces.renderkit.html.util.AutoScrollPhaseListener</phase-listener>
   </lifecycle>
-  <!-- 
+ 
   <factory>
       <faces-context-factory>org.apache.myfaces.webapp.filter.TomahawkFacesContextFactory</faces-context-factory>
   </factory>
-   -->
+
     <!-- additional "by type" converters -->
     
     <converter>

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java?rev=669711&r1=669710&r2=669711&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilter.java Thu Jun 19 14:49:59 2008
@@ -196,9 +196,10 @@
         HttpServletRequest extendedRequest = httpRequest;
 
         // For multipart/form-data requests
-        if (FileUpload.isMultipartContent(httpRequest)) {
-            extendedRequest = new MultipartRequestWrapper(httpRequest, _uploadMaxFileSize, _uploadThresholdSize, _uploadRepositoryPath);
-        }
+        // This is done by TomahawkFacesContextWrapper
+        //if (FileUpload.isMultipartContent(httpRequest)) {
+        //    extendedRequest = new MultipartRequestWrapper(httpRequest, _uploadMaxFileSize, _uploadThresholdSize, _uploadRepositoryPath);
+        //}
 
         // Serve resources
         AddResource addResource;

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilterConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilterConfig.java?rev=669711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilterConfig.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilterConfig.java Thu Jun 19 14:49:59 2008
@@ -0,0 +1,414 @@
+/*
+ * 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.myfaces.webapp.filter;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.context.ExternalContext;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.shared_tomahawk.config.MyfacesConfig;
+import org.apache.myfaces.shared_tomahawk.util.xml.MyFacesErrorHandler;
+import org.apache.myfaces.shared_tomahawk.util.xml.XmlUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
+/**
+ *  This class is used to retrieve the configuration of the ExtensionsFilter
+ * and read it by TomahawkFacesContexWrapper, because it is necessary for
+ * initialize properly MultipartRequestWrapper.
+ * 
+ * For do that, it parse the file /WEB-INF/web.xml
+ * 
+ * It also uses a mechanism similar to shared WebXml to refresh the params.
+ * 
+ * @author Leonardo Uribe
+ *
+ */
+public class ExtensionsFilterConfig
+{
+    
+    private int _uploadMaxFileSize = 100 * 1024 * 1024; // 10 MB
+
+    private int _uploadThresholdSize = 1 * 1024 * 1024; // 1 MB
+
+    private String _uploadRepositoryPath = null; //standard temp directory
+    
+    public int getUploadMaxFileSize()
+    {
+        return _uploadMaxFileSize;
+    }
+
+    protected void setUploadMaxFileSize(int uploadMaxFileSize)
+    {
+        this._uploadMaxFileSize = uploadMaxFileSize;
+    }
+
+    protected int getUploadThresholdSize()
+    {
+        return _uploadThresholdSize;
+    }
+
+    protected void setUploadThresholdSize(int uploadThresholdSize)
+    {
+        this._uploadThresholdSize = uploadThresholdSize;
+    }
+
+    public String getUploadRepositoryPath()
+    {
+        return _uploadRepositoryPath;
+    }
+
+    protected void setUploadRepositoryPath(String uploadRepositoryPath)
+    {
+        this._uploadRepositoryPath = uploadRepositoryPath;
+    }    
+    
+    //Static stuff
+    
+    private static final String WEB_XML_PATH = "/WEB-INF/web.xml";
+    private static final String WEB_APP_2_2_J2EE_SYSTEM_ID = "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd";
+    private static final String WEB_APP_2_2_SYSTEM_ID = "http://java.sun.com/dtd/web-app_2_2.dtd";
+    private static final String WEB_APP_2_2_RESOURCE  = "javax/servlet/resources/web-app_2_2.dtd";
+
+    private static final String WEB_APP_2_3_SYSTEM_ID = "http://java.sun.com/dtd/web-app_2_3.dtd";
+    private static final String WEB_APP_2_3_RESOURCE  = "javax/servlet/resources/web-app_2_3.dtd";
+    
+    private static final Log log = LogFactory.getLog(ExtensionsFilterConfig.class);
+    
+    private long parsingTime;
+    
+    private static long refreshPeriod;    
+    
+    protected void setParsingTime(long parsingTime){
+        this.parsingTime = parsingTime;
+    }
+    
+    public static ExtensionsFilterConfig parse(ExternalContext context)
+    {
+        ExtensionsFilterConfigParser parser = new ExtensionsFilterConfigParser(context);
+        return parser.parse();
+    }
+    
+    protected static class ExtensionsFilterConfigParser
+    {
+        private ExternalContext _context;
+        private ExtensionsFilterConfig _extensionsFilterConfig;
+        
+        public ExtensionsFilterConfigParser(ExternalContext context)
+        {
+            _context = context;
+        }
+        
+        public ExtensionsFilterConfig parse()
+        {
+            _extensionsFilterConfig = new ExtensionsFilterConfig();
+
+            try
+            {
+                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+                dbf.setIgnoringElementContentWhitespace(true);
+                dbf.setIgnoringComments(true);
+                dbf.setNamespaceAware(true);
+                dbf.setValidating(false);
+//                dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
+
+                DocumentBuilder db = dbf.newDocumentBuilder();
+                db.setEntityResolver(new _EntityResolver());
+                db.setErrorHandler(new MyFacesErrorHandler(log));
+
+                InputSource is = createContextInputSource(null, WEB_XML_PATH);
+
+                if(is==null)
+                {
+                    URL url = _context.getResource(WEB_XML_PATH);
+                    log.debug("No web-xml found at : "+(url==null?" null ":url.toString()));
+                    return _extensionsFilterConfig;
+                }
+
+                Document document = db.parse(is);
+
+                Element webAppElem = document.getDocumentElement();
+                if (webAppElem == null ||
+                    !webAppElem.getNodeName().equals("web-app"))
+                {
+                    throw new FacesException("No valid web-app root element found!");
+                }
+
+                readWebApp(webAppElem);
+
+                return _extensionsFilterConfig;
+            }
+            catch (Exception e)
+            {
+                log.fatal("Unable to parse web.xml", e);
+                throw new FacesException(e);
+            }
+        }
+        
+        private void readWebApp(Element webAppElem)
+        {
+            NodeList nodeList = webAppElem.getChildNodes();
+            for (int i = 0, len = nodeList.getLength(); i < len; i++)
+            {
+                Node n = nodeList.item(i);
+                if (n.getNodeType() == Node.ELEMENT_NODE)
+                {
+                    if (n.getNodeName().equals("filter"))
+                    {
+                        readFilter((Element)n);
+                    }
+                }
+                else
+                {
+                    if (log.isDebugEnabled()) log.debug("Ignored node '" + n.getNodeName() + "' of type " + n.getNodeType());
+                }
+            }
+        }
+        
+        private void readFilter(Element filterElem)
+        {
+            String filterName = null;
+            String filterClass = null;
+            Map initParams = new HashMap();
+            NodeList nodeList = filterElem.getChildNodes();
+            for (int i = 0, len = nodeList.getLength(); i < len; i++)
+            {
+                Node n = nodeList.item(i);
+                if (n.getNodeType() == Node.ELEMENT_NODE)
+                {
+                    if (n.getNodeName().equals("filter-name"))
+                    {
+                        filterName = XmlUtils.getElementText((Element)n).trim();
+                    }
+                    else if (n.getNodeName().equals("filter-class"))
+                    {
+                        filterClass = org.apache.myfaces.shared_tomahawk.util.xml.XmlUtils.getElementText((Element)n).trim();
+                    }
+                    else if (n.getNodeName().equals("description") || n.getNodeName().equals("init-param"))
+                    {
+                        //ignore
+                    }
+                    else if (n.getNodeName().equals("init-param"))
+                    {
+                        //Read the extensions filter params!
+                        NodeList nodeList2 = n.getChildNodes();
+                        String paramName = null;
+                        String paramValue =  null;
+                        for (int j = 0, len2 = nodeList2.getLength(); j < len2; j++)
+                        {
+                            Node n2 = nodeList2.item(j);
+                            if(n2.getNodeName().equals("param-name"))
+                            {
+                                paramName = XmlUtils.getElementText((Element)n2).trim();
+                            }
+                            else if (n2.getNodeName().equals("param-value"))
+                            {
+                                paramValue = XmlUtils.getElementText((Element)n2).trim();
+                            }
+                        }
+                        
+                        if (paramName != null)
+                        {
+                            initParams.put(paramName, paramValue);
+                        }
+                    }
+                    else
+                    {
+                        if (log.isDebugEnabled()) log.debug("Ignored element '" + n.getNodeName() + "' as child of '" + filterElem.getNodeName() + "'.");
+                    }
+                }
+                else
+                {
+                    if (log.isDebugEnabled()) log.debug("Ignored node '" + n.getNodeName() + "' of type " + n.getNodeType());
+                }
+            }
+            
+            if ("org.apache.myfaces.webapp.filter.ExtensionsFilter".equals(filterClass))
+            {
+                //Read extensions filter params
+                String param = (String)initParams.get("uploadMaxFileSize");
+
+                _extensionsFilterConfig._uploadMaxFileSize = resolveSize(param, _extensionsFilterConfig._uploadMaxFileSize);
+
+                param = (String)initParams.get("uploadThresholdSize");
+
+                _extensionsFilterConfig._uploadThresholdSize = resolveSize(param, _extensionsFilterConfig._uploadThresholdSize);
+
+                _extensionsFilterConfig._uploadRepositoryPath = (String)initParams.get("uploadRepositoryPath");
+            }            
+            initParams.clear();
+            //_webXml.addFilter(filterName, filterClass);
+        }
+        
+        private int resolveSize(String param, int defaultValue) {
+            int numberParam = defaultValue;
+
+            if (param != null) {
+                param = param.toLowerCase();
+                int factor = 1;
+                String number = param;
+
+                if (param.endsWith("g")) {
+                    factor = 1024 * 1024 * 1024;
+                    number = param.substring(0, param.length() - 1);
+                } else if (param.endsWith("m")) {
+                    factor = 1024 * 1024;
+                    number = param.substring(0, param.length() - 1);
+                } else if (param.endsWith("k")) {
+                    factor = 1024;
+                    number = param.substring(0, param.length() - 1);
+                }
+
+                numberParam = Integer.parseInt(number) * factor;
+            }
+            return numberParam;
+        }
+        
+                        
+        private class _EntityResolver implements EntityResolver
+        {
+            public InputSource resolveEntity(String publicId, String systemId) throws IOException
+            {
+                if (systemId == null)
+                {
+                    throw new UnsupportedOperationException("systemId must not be null");
+                }
+
+                if (systemId.equals(WEB_APP_2_2_SYSTEM_ID) ||
+                    systemId.equals(WEB_APP_2_2_J2EE_SYSTEM_ID))
+                {
+                    //Load DTD from servlet.jar
+                    return createClassloaderInputSource(publicId,WEB_APP_2_2_RESOURCE);
+                }
+                else if (systemId.equals(WEB_APP_2_3_SYSTEM_ID))
+                {
+                    //Load DTD from servlet.jar
+                    return createClassloaderInputSource(publicId,WEB_APP_2_3_RESOURCE);
+                }
+                else
+                {
+                    //Load additional entities from web context
+                    return createContextInputSource(publicId, systemId);
+                }
+            }
+        }
+        
+        private InputSource createContextInputSource(String publicId, String systemId)
+        {
+            InputStream inStream = _context.getResourceAsStream(systemId);
+            if (inStream == null)
+            {
+                // there is no such entity
+                return null;
+            }
+            InputSource is = new InputSource(inStream);
+            is.setPublicId(publicId);
+            is.setSystemId(systemId);
+            //the next line was removed - encoding should be determined automatically out of the inputStream
+            //DEFAULT_ENCODING was ISO-8859-1
+            //is.setEncoding(DEFAULT_ENCODING);
+            return is;
+        }
+        
+        private InputSource createClassloaderInputSource(String publicId, String systemId)
+        {
+            InputStream inStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(systemId);
+            if (inStream == null)
+            {
+                // there is no such entity
+                return null;
+            }
+            InputSource is = new InputSource(inStream);
+            is.setPublicId(publicId);
+            is.setSystemId(systemId);
+            //the next line was removed - encoding should be determined automatically out of the inputStream
+            //encoding should be determined automatically out of the inputStream
+            //DEFAULT_ENCODING was ISO-8859-1
+            //is.setEncoding(DEFAULT_ENCODING);
+            return is;
+        }
+    }
+    
+    protected boolean isOld(ExternalContext context) {
+        if (refreshPeriod > 0) {
+            long ttl = this.parsingTime + refreshPeriod;
+            if (System.currentTimeMillis() > ttl) {
+                long lastModified = ExtensionsFilterConfig.getWebXmlLastModified(context);
+                return lastModified == 0 || lastModified > ttl;
+            }
+        }
+        return false;
+    }
+    
+    public static long getWebXmlLastModified(ExternalContext context) {
+        try {
+            URL url = context.getResource(WEB_XML_PATH);
+            if (url != null)
+                return url.openConnection().getLastModified();
+        } catch (IOException e) {
+            log.error("Could not find web.xml in path " + WEB_XML_PATH);
+        }
+        return 0L;
+    }
+            
+    private static final String EXTENSIONS_FILTER_CONFIG = ExtensionsFilterConfig.class.getName();
+    
+    public static ExtensionsFilterConfig getExtensionsFilterConfig(ExternalContext context)
+    {
+        ExtensionsFilterConfig configuration = (ExtensionsFilterConfig)context.getApplicationMap().get(EXTENSIONS_FILTER_CONFIG);
+        if (configuration == null)
+        {
+            init(context);
+            configuration = (ExtensionsFilterConfig)context.getApplicationMap().get(EXTENSIONS_FILTER_CONFIG);
+        }
+        return configuration;
+    }
+
+    /**
+     * should be called when initialising Servlet
+     * @param context
+     */
+    public static void init(ExternalContext context)
+    {
+        ExtensionsFilterConfig configuration = ExtensionsFilterConfig.parse(context);
+        context.getApplicationMap().put(EXTENSIONS_FILTER_CONFIG, configuration);
+        long configRefreshPeriod = MyfacesConfig.getCurrentInstance(context).getConfigRefreshPeriod();
+        configuration.setParsingTime(System.currentTimeMillis());
+        refreshPeriod = (configRefreshPeriod * 1000);
+    }
+    public static void update(ExternalContext context){
+        if (getExtensionsFilterConfig(context).isOld(context)){
+            ExtensionsFilterConfig.init(context);
+        }
+    }
+
+}

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilterConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/ExtensionsFilterConfig.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextWrapper.java?rev=669711&r1=669710&r2=669711&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextWrapper.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/TomahawkFacesContextWrapper.java Thu Jun 19 14:49:59 2008
@@ -38,6 +38,8 @@
 import org.apache.myfaces.renderkit.html.util.AddResource;
 import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
 import org.apache.myfaces.tomahawk.util.ExternalContextUtils;
+import org.apache.myfaces.webapp.filter.portlet.PortletExternalContextWrapper;
+import org.apache.myfaces.webapp.filter.servlet.ServletExternalContextWrapper;
 
 /**
  * @author Martin Marinschek
@@ -55,6 +57,16 @@
         //if(delegate.getExternalContext().getResponse() instanceof PortletResponse) {
         if(ExternalContextUtils.getRequestType(delegate.getExternalContext()).isPortlet()) {
             //todo do something here - with the multipart-wrapper. rest should be fine
+            //javax.portlet.PortletRequest portletRequest = (javax.portlet.PortletRequest) delegate.getExternalContext().getRequest();
+            
+            //Object portletResponse = delegate.getExternalContext().getResponse();
+            //Object portletRequest = delegate.getExternalContext().getRequest();
+
+            //Object extendedRequest = portletRequest;
+            //Object extendedResponse = portletResponse;
+            
+            //boolean multipartContent = false;            
+            
             AddResource addResource= AddResourceFactory.getInstance(this);
             addResource.responseStarted();
 
@@ -64,6 +76,9 @@
                         " Use for org.apache.myfaces.ADD_RESOURCE_CLASS the value"+
                         " org.apache.myfaces.renderkit.html.util.NonBufferingAddResource.");
             }
+	        
+	        //externalContextDelegate = new PortletExternalContextWrapper(
+	        //        delegate.getExternalContext(), extendedRequest, extendedResponse, multipartContent);
         }
         else {
             HttpServletResponse httpResponse = (HttpServletResponse) delegate.getExternalContext().getResponse();
@@ -73,9 +88,13 @@
             HttpServletResponse extendedResponse = httpResponse;
 
             // For multipart/form-data requests
+            boolean multipartContent = false;
             if (FileUpload.isMultipartContent(httpRequest)) {
-                extendedRequest = new MultipartRequestWrapper(httpRequest, /*todo _uploadMaxFileSize*/-1,
-                        /*todo _uploadThresholdSize*/-1, /*todo _uploadRepositoryPath*/null);
+                multipartContent = true;
+                ExtensionsFilterConfig config = ExtensionsFilterConfig.
+                    getExtensionsFilterConfig(delegate.getExternalContext());
+                extendedRequest = new MultipartRequestWrapper(httpRequest, config.getUploadMaxFileSize(),
+                        config.getUploadThresholdSize(), config.getUploadRepositoryPath());
             }
 
             AddResource addResource= AddResourceFactory.getInstance(this);
@@ -87,11 +106,11 @@
 		        extendedResponse = extensionsResponseWrapper;
             }
 
-            externalContextDelegate = new ExternalContextWrapper(
-                    delegate.getExternalContext(), extendedRequest, extendedResponse);
+            externalContextDelegate = new ServletExternalContextWrapper(
+                    delegate.getExternalContext(), extendedRequest, extendedResponse, multipartContent);            
         }
     }
-
+    
     /**
      * This method uses reflection to call the method of the delegated
      * FacesContext getELContext, present on 1.2. This should be done

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/PortletExternalContextWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/PortletExternalContextWrapper.java?rev=669711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/PortletExternalContextWrapper.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/PortletExternalContextWrapper.java Thu Jun 19 14:49:59 2008
@@ -0,0 +1,411 @@
+/*
+ * 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.myfaces.webapp.filter.portlet;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.context.ExternalContext;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+
+/**
+ * This class encapsulate the ExternalContext given, adding support for
+ * inputFileUpload (necessary when this is encapsulated with 
+ * MultipartRequestWrapper). For make available the parameters map on a
+ * multipart content request, it is necessary to encapsulate the original
+ * request with MultipartRequestWrapper, but the original ExternalContext
+ * is tied with the original request so we need to do this wrapper using
+ * the delegate pattern starting with TomahawkFacesContextFactory. 
+ * 
+ * @author Martin Marinschek
+ */
+public class PortletExternalContextWrapper extends ExternalContext {
+    private ExternalContext _delegate;
+    private PortletRequest _portletRequest;
+    private PortletResponse _portletResponse;
+    private boolean _multipartContent;
+
+    //This maps are only used if multipartContent = true
+    private Map _sessionMap;
+    private Map _requestMap;
+    private Map _requestParameterMap;
+    private Map _requestParameterValuesMap;
+    private Map _requestHeaderMap;
+    private Map _requestHeaderValuesMap;
+    //end multipartContent = true;
+
+    public PortletExternalContextWrapper(ExternalContext delegate, Object request, Object response, boolean multipartContent) {
+        this._delegate = delegate;
+        this._portletRequest = (PortletRequest)request;
+        this._portletResponse = (PortletResponse)response;
+        this._multipartContent = multipartContent;
+    }
+
+    public void dispatch(String path) throws IOException {
+        _delegate.dispatch(path);
+    }
+
+    public String encodeActionURL(String url) {
+        return _delegate.encodeActionURL(url);
+    }
+
+    public String encodeNamespace(String name) {
+        return _delegate.encodeNamespace(name);
+    }
+
+    public String encodeResourceURL(String url) {
+        return _delegate.encodeResourceURL(url);
+    }
+
+    public Map getApplicationMap() {
+        return _delegate.getApplicationMap();
+    }
+
+    public String getAuthType() {
+        return _delegate.getAuthType();
+    }
+
+    public Object getContext() {
+        return _delegate.getContext();
+    }
+
+    public String getInitParameter(String name) {
+        return _delegate.getInitParameter(name);
+    }
+
+    public Map getInitParameterMap() {
+        return _delegate.getInitParameterMap();
+    }
+
+    public String getRemoteUser() {
+        return _delegate.getRemoteUser();
+    }
+
+    public Object getRequest() {
+        return _portletRequest==null?_delegate.getRequest():_portletRequest;
+    }
+
+    public String getRequestContextPath() {
+        return _delegate.getRequestContextPath();
+    }
+
+    public Map getRequestCookieMap() {
+        return _delegate.getRequestCookieMap();
+    }
+
+    public Map getRequestHeaderMap() {
+        if (_multipartContent)
+        {
+            if (_requestHeaderMap == null)
+            {
+                _requestHeaderMap = new RequestHeaderMap((PortletRequest)_portletRequest);
+            }
+            return _requestHeaderMap;                        
+        }
+        else
+        {
+            return _delegate.getRequestHeaderMap();
+        }
+    }
+
+    public Map getRequestHeaderValuesMap() {
+        if (_multipartContent)
+        {
+            if (_requestHeaderValuesMap == null)
+            {
+                _requestHeaderValuesMap = new RequestHeaderValuesMap((PortletRequest)_portletRequest);
+            }
+            return _requestHeaderValuesMap;
+        }
+        else
+        {        
+            return _delegate.getRequestHeaderValuesMap();
+        }
+    }
+
+    public Locale getRequestLocale() {
+        return _delegate.getRequestLocale();
+    }
+
+    public Iterator getRequestLocales() {
+        return _delegate.getRequestLocales();
+    }
+
+    public Map getRequestMap() {
+        if (_multipartContent)
+        {            
+            if (_requestMap == null)
+            {
+                _requestMap = new RequestMap(_portletRequest);
+            }
+            return _requestMap;
+        }
+        else
+        {
+            return _delegate.getRequestMap();
+        }
+    }
+
+    public Map getRequestParameterMap() {
+        if (_multipartContent)
+        {            
+            if (_requestParameterMap == null)
+            {
+                _requestParameterMap = new RequestParameterMap(_portletRequest);
+            }
+            return _requestParameterMap;
+        }
+        else
+        {        
+            return _delegate.getRequestParameterMap();
+        }
+    }
+
+    public Iterator getRequestParameterNames() {
+        if (_multipartContent)
+        {            
+            final Enumeration enumer = _portletRequest.getParameterNames();
+            Iterator it = new Iterator()
+            {
+                public boolean hasNext() {
+                    return enumer.hasMoreElements();
+                }
+
+                public Object next() {
+                    return enumer.nextElement();
+                }
+
+                public void remove() {
+                    throw new UnsupportedOperationException(this.getClass().getName() + " UnsupportedOperationException");
+                }
+            };
+            return it;
+        }
+        else
+        {        
+            return _delegate.getRequestParameterNames();
+        }
+    }
+
+    public Map getRequestParameterValuesMap() {
+        if (_multipartContent)
+        {            
+            if (_requestParameterValuesMap == null)
+            {
+                _requestParameterValuesMap = new RequestParameterValuesMap(_portletRequest);
+            }
+            return _requestParameterValuesMap;
+        }
+        else
+        {        
+            return _delegate.getRequestParameterValuesMap();
+        }
+    }
+
+    public String getRequestPathInfo() {
+        return _delegate.getRequestPathInfo();
+    }
+
+    public String getRequestServletPath() {
+        return _delegate.getRequestServletPath();
+    }
+
+    public URL getResource(String path) throws MalformedURLException {
+        return _delegate.getResource(path);
+    }
+
+    public InputStream getResourceAsStream(String path) {
+        return _delegate.getResourceAsStream(path);
+    }
+
+    public Set getResourcePaths(String path) {
+        return _delegate.getResourcePaths(path);
+    }
+
+    public Object getResponse() {
+        return _portletResponse==null?_delegate.getResponse():_portletResponse;
+    }
+
+    public Object getSession(boolean create) {
+        return _delegate.getSession(create);
+    }
+
+    public Map getSessionMap() {
+        if (_multipartContent)
+        {            
+            if (_sessionMap == null)
+            {
+                _sessionMap = new SessionMap((PortletRequest) _portletRequest);
+            }
+            return _sessionMap;
+        }
+        else
+        {
+            return _delegate.getSessionMap();            
+        }
+    }
+
+    public Principal getUserPrincipal() {
+        return _delegate.getUserPrincipal();
+    }
+
+    public boolean isUserInRole(String role) {
+        return _delegate.isUserInRole(role);
+    }
+
+    public void log(String message) {
+        _delegate.log(message);
+    }
+
+    public void log(String message, Throwable exception) {
+        _delegate.log(message, exception);
+    }
+
+    public void redirect(String url) throws IOException {
+        _delegate.redirect(url);
+    }
+    
+    //Methods since 1.2
+    
+    public String getResponseContentType()
+    {
+        try
+        {
+            Method method = _delegate.getClass().getMethod(
+                    "getResponseContentType", 
+                    null);
+            return (String) method.invoke(_delegate, null);
+        }
+        catch (NoSuchMethodException e)
+        {
+            throw new RuntimeException("JSF 1.2 method not implemented: "+e.getMessage());
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException("Error calling JSF 1.2 method: "+e.getMessage());
+        }
+    }
+
+    public void setRequest(java.lang.Object request)
+    {
+        try
+        {
+            Method method = _delegate.getClass().getMethod(
+                    "setRequest", 
+                    new Class[]{java.lang.Object.class});
+            method.invoke(_delegate, new Object[]{request});
+        }
+        catch (NoSuchMethodException e)
+        {
+            throw new RuntimeException("JSF 1.2 method not implemented: "+e.getMessage());
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException("Error calling JSF 1.2 method: "+e.getMessage());
+        }
+    }
+
+    public void setRequestCharacterEncoding(java.lang.String encoding)
+        throws java.io.UnsupportedEncodingException{
+
+        try
+        {
+            Method method = _delegate.getClass().getMethod(
+                    "setRequestCharacterEncoding", 
+                    new Class[]{java.lang.String.class});
+            method.invoke(_delegate, new Object[]{encoding});
+        }
+        catch (NoSuchMethodException e)
+        {
+            throw new RuntimeException("JSF 1.2 method not implemented: "+e.getMessage());
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException("Error calling JSF 1.2 method: "+e.getMessage());
+        }
+    }
+    
+    public void setResponse(java.lang.Object response)
+    {
+        try
+        {
+            Method method = _delegate.getClass().getMethod(
+                    "setResponse", 
+                    new Class[]{java.lang.Object.class});
+            method.invoke(_delegate, new Object[]{response});
+        }
+        catch (NoSuchMethodException e)
+        {
+            throw new RuntimeException("JSF 1.2 method not implemented: "+e.getMessage());
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException("Error calling JSF 1.2 method: "+e.getMessage());
+        }
+    }
+    
+    public void setResponseCharacterEncoding(java.lang.String encoding)
+    {
+        try
+        {
+            Method method = _delegate.getClass().getMethod(
+                    "setResponseCharacterEncoding", 
+                    new Class[]{java.lang.String.class});
+            method.invoke(_delegate, new Object[]{encoding});
+        }
+        catch (NoSuchMethodException e)
+        {
+            throw new RuntimeException("JSF 1.2 method not implemented: "+e.getMessage());
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException("Error calling JSF 1.2 method: "+e.getMessage());
+        }
+    }
+
+    public String getResponseCharacterEncoding()
+    {
+        try
+        {
+            Method method = _delegate.getClass().getMethod(
+                    "getResponseCharacterEncoding", 
+                    null);
+            return (String) method.invoke(_delegate, null);
+        }
+        catch (NoSuchMethodException e)
+        {
+            throw new RuntimeException("JSF 1.2 method not implemented: "+e.getMessage());
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException("Error calling JSF 1.2 method: "+e.getMessage());
+        }
+    }
+        
+}

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/PortletExternalContextWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/PortletExternalContextWrapper.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestHeaderMap.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestHeaderMap.java?rev=669711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestHeaderMap.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestHeaderMap.java Thu Jun 19 14:49:59 2008
@@ -0,0 +1,75 @@
+/*
+ * 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.myfaces.webapp.filter.portlet;
+
+import java.util.Enumeration;
+import java.util.Map;
+
+import javax.portlet.PortletRequest;
+
+import org.apache.myfaces.webapp.filter.servlet.AbstractAttributeMap;
+
+/**
+ * PortletRequest headers as Map.
+ *
+ * @author  Stan Silvert (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class RequestHeaderMap extends AbstractAttributeMap
+{
+    private final PortletRequest _portletRequest;
+
+    RequestHeaderMap(PortletRequest portletRequest)
+    {
+        _portletRequest = portletRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        return _portletRequest.getProperty(key);
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot set PortletRequest property");
+    }
+
+    protected void removeAttribute(String key)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot remove PortletRequest property");
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _portletRequest.getPropertyNames();
+    }
+
+    public void putAll(Map t)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public void clear()
+    {
+        throw new UnsupportedOperationException();
+    }    
+}

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestHeaderMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestHeaderMap.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestHeaderValuesMap.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestHeaderValuesMap.java?rev=669711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestHeaderValuesMap.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestHeaderValuesMap.java Thu Jun 19 14:49:59 2008
@@ -0,0 +1,86 @@
+/*
+ * 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.myfaces.webapp.filter.portlet;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.portlet.PortletRequest;
+
+import org.apache.myfaces.webapp.filter.servlet.AbstractAttributeMap;
+
+/**
+ * PortletRequest header values (multi-value headers) as Map of String[].
+ *
+ * @author  Stan Silvert (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class RequestHeaderValuesMap extends AbstractAttributeMap
+{
+    private final PortletRequest _portletRequest;
+    private final Map            _valueCache = new HashMap();
+
+    RequestHeaderValuesMap(PortletRequest portletRequest)
+    {
+        _portletRequest = portletRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        Object ret = _valueCache.get(key);
+        if (ret == null)
+        {
+            _valueCache.put(key, ret = toArray(_portletRequest
+                .getProperties(key)));
+        }
+
+        return ret;
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot set PortletRequest Properties");
+    }
+
+    protected void removeAttribute(String key)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot remove PortletRequest Properties");
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _portletRequest.getPropertyNames();
+    }
+
+    private String[] toArray(Enumeration e)
+    {
+        List ret = new ArrayList();
+
+        while (e.hasMoreElements())
+        {
+            ret.add(e.nextElement());
+        }
+
+        return (String[]) ret.toArray(new String[ret.size()]);
+    }
+}
\ No newline at end of file

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestHeaderValuesMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestHeaderValuesMap.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestMap.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestMap.java?rev=669711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestMap.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestMap.java Thu Jun 19 14:49:59 2008
@@ -0,0 +1,72 @@
+/*
+ * 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.myfaces.webapp.filter.portlet;
+
+import java.util.Enumeration;
+import java.util.Map;
+import javax.portlet.PortletRequest;
+import org.apache.myfaces.webapp.filter.servlet.AbstractAttributeMap;
+
+
+/**
+ * PortletRequest attributes Map.
+ *
+ * @author  Stan Silvert (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class RequestMap extends AbstractAttributeMap
+{
+    final PortletRequest _portletRequest;
+
+    RequestMap(PortletRequest portletRequest)
+    {
+        _portletRequest = portletRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        return _portletRequest.getAttribute(key);
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        _portletRequest.setAttribute(key, value);
+    }
+
+    protected void removeAttribute(String key)
+    {
+        _portletRequest.removeAttribute(key);
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _portletRequest.getAttributeNames();
+    }
+
+    public void putAll(Map t)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public void clear()
+    {
+        throw new UnsupportedOperationException();
+    }    
+}

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestMap.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestParameterMap.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestParameterMap.java?rev=669711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestParameterMap.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestParameterMap.java Thu Jun 19 14:49:59 2008
@@ -0,0 +1,62 @@
+/*
+ * 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.myfaces.webapp.filter.portlet;
+
+import java.util.Enumeration;
+import javax.portlet.PortletRequest;
+
+import org.apache.myfaces.webapp.filter.servlet.AbstractAttributeMap;
+
+/**
+ * PortletRequest parameters as Map.
+ *
+ * @author  Stan Silvert (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class RequestParameterMap extends AbstractAttributeMap
+{
+    private final PortletRequest _portletRequest;
+
+    RequestParameterMap(PortletRequest portletRequest)
+    {
+        _portletRequest = portletRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        return _portletRequest.getParameter(key);
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot set PortletRequest Parameter");
+    }
+
+    protected void removeAttribute(String key)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot remove PortletRequest Parameter");
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _portletRequest.getParameterNames();
+    }
+}
\ No newline at end of file

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestParameterMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestParameterMap.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestParameterValuesMap.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestParameterValuesMap.java?rev=669711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestParameterValuesMap.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestParameterValuesMap.java Thu Jun 19 14:49:59 2008
@@ -0,0 +1,61 @@
+/*
+ * 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.myfaces.webapp.filter.portlet;
+
+import java.util.Enumeration;
+import javax.portlet.PortletRequest;
+import org.apache.myfaces.webapp.filter.servlet.AbstractAttributeMap;
+
+/**
+ * PortletRequest multi-value parameters as Map.
+ *
+ * @author  Stan Silvert (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class RequestParameterValuesMap extends AbstractAttributeMap
+{
+    private final PortletRequest _portletRequest;
+
+    RequestParameterValuesMap(PortletRequest portletRequest)
+    {
+        _portletRequest = portletRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        return _portletRequest.getParameterValues(key);
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot set PortletRequest ParameterValues");
+    }
+
+    protected void removeAttribute(String key)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot remove PortletRequest ParameterValues");
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _portletRequest.getParameterNames();
+    }
+}
\ No newline at end of file

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestParameterValuesMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/RequestParameterValuesMap.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/SessionMap.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/SessionMap.java?rev=669711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/SessionMap.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/SessionMap.java Thu Jun 19 14:49:59 2008
@@ -0,0 +1,88 @@
+/*
+ * 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.myfaces.webapp.filter.portlet;
+
+import org.apache.myfaces.shared_tomahawk.util.NullEnumeration;
+
+import java.util.Enumeration;
+import java.util.Map;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import org.apache.myfaces.webapp.filter.servlet.AbstractAttributeMap;
+
+/**
+ * Portlet scope PortletSession attibutes as Map.
+ *
+ * @author  Stan Silvert (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class SessionMap extends AbstractAttributeMap
+{
+    private final PortletRequest _portletRequest;
+
+    SessionMap(PortletRequest portletRequest)
+    {
+        _portletRequest = portletRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        PortletSession portletSession = getSession();
+        return (portletSession == null)
+               ? null : portletSession.getAttribute(key.toString(), PortletSession.PORTLET_SCOPE);
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        _portletRequest.getPortletSession(true).setAttribute(key, value, PortletSession.PORTLET_SCOPE);
+    }
+
+    protected void removeAttribute(String key)
+    {
+        PortletSession portletSession = getSession();
+        if (portletSession != null)
+        {
+            portletSession.removeAttribute(key, PortletSession.PORTLET_SCOPE);
+        }
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        PortletSession portletSession = getSession();
+        return (portletSession == null)
+               ? NullEnumeration.instance()
+               : portletSession.getAttributeNames(PortletSession.PORTLET_SCOPE);
+    }
+
+    private PortletSession getSession()
+    {
+        return _portletRequest.getPortletSession(false);
+    }
+
+    public void putAll(Map t)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public void clear()
+    {
+        throw new UnsupportedOperationException();
+    }
+}
\ No newline at end of file

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/SessionMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/portlet/SessionMap.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/AbstractAttributeMap.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/AbstractAttributeMap.java?rev=669711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/AbstractAttributeMap.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/AbstractAttributeMap.java Thu Jun 19 14:49:59 2008
@@ -0,0 +1,351 @@
+/*
+ * 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.myfaces.webapp.filter.servlet;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+
+/**
+ * Helper Map implementation for use with different Attribute Maps.
+ *
+ * @author Anton Koinov (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public abstract class AbstractAttributeMap
+    extends AbstractMap
+{
+    private Set              _keySet;
+    private Collection       _values;
+    private Set              _entrySet;
+
+    public void clear()
+    {
+        List names = new ArrayList();
+        for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
+        {
+            names.add(e.nextElement());
+        }
+
+        for (Iterator it = names.iterator(); it.hasNext();)
+        {
+            removeAttribute((String) it.next());
+        }
+    }
+
+    public boolean containsKey(Object key)
+    {
+        return getAttribute(key.toString()) != null;
+    }
+
+    public boolean containsValue(Object findValue)
+    {
+        if (findValue == null)
+        {
+            return false;
+        }
+
+        for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
+        {
+            Object value = getAttribute((String) e.nextElement());
+            if (findValue.equals(value))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public Set entrySet()
+    {
+        return (_entrySet != null) ? _entrySet : (_entrySet = new EntrySet());
+    }
+
+    public Object get(Object key)
+    {
+        return getAttribute(key.toString());
+    }
+
+    public boolean isEmpty()
+    {
+        return !getAttributeNames().hasMoreElements();
+    }
+
+    public Set keySet()
+    {
+        return (_keySet != null) ? _keySet : (_keySet = new KeySet());
+    }
+
+    public Object put(Object key, Object value)
+    {
+        String key_ = key.toString();
+        Object retval = getAttribute(key_);
+        setAttribute(key_, value);
+        return retval;
+    }
+
+    public void putAll(Map t)
+    {
+        for (Iterator it = t.entrySet().iterator(); it.hasNext();)
+        {
+            Entry entry = (Entry) it.next();
+            setAttribute(entry.getKey().toString(), entry.getValue());
+        }
+    }
+
+    public Object remove(Object key)
+    {
+        String key_ = key.toString();
+        Object retval = getAttribute(key_);
+        removeAttribute(key_);
+        return retval;
+    }
+
+    public int size()
+    {
+        int size = 0;
+        for (Enumeration e = getAttributeNames(); e.hasMoreElements();)
+        {
+            size++;
+            e.nextElement();
+        }
+        return size;
+    }
+
+    public Collection values()
+    {
+        return (_values != null) ? _values : (_values = new Values());
+    }
+
+
+    abstract protected Object getAttribute(String key);
+
+    abstract protected void setAttribute(String key, Object value);
+
+    abstract protected void removeAttribute(String key);
+
+    abstract protected Enumeration getAttributeNames();
+
+
+    private class KeySet extends AbstractSet
+    {
+        public Iterator iterator()
+        {
+            return new KeyIterator();
+        }
+
+        public boolean isEmpty()
+        {
+            return AbstractAttributeMap.this.isEmpty();
+        }
+
+        public int size()
+        {
+            return AbstractAttributeMap.this.size();
+        }
+
+        public boolean contains(Object o)
+        {
+            return AbstractAttributeMap.this.containsKey(o);
+        }
+
+        public boolean remove(Object o)
+        {
+            return AbstractAttributeMap.this.remove(o) != null;
+        }
+
+        public void clear()
+        {
+            AbstractAttributeMap.this.clear();
+        }
+    }
+
+    private class KeyIterator
+        implements Iterator
+    {
+        protected final Enumeration _e = getAttributeNames();
+        protected Object            _currentKey;
+
+        public void remove()
+        {
+            // remove() may cause ConcurrentModificationException.
+            // We could throw an exception here, but not throwing an exception
+            //   allows one call to remove() to succeed
+            if (_currentKey == null)
+            {
+                throw new NoSuchElementException(
+                    "You must call next() at least once");
+            }
+            AbstractAttributeMap.this.remove(_currentKey);
+        }
+
+        public boolean hasNext()
+        {
+            return _e.hasMoreElements();
+        }
+
+        public Object next()
+        {
+            return _currentKey = _e.nextElement();
+        }
+    }
+
+    private class Values extends KeySet
+    {
+        public Iterator iterator()
+        {
+            return new ValuesIterator();
+        }
+
+        public boolean contains(Object o)
+        {
+            return AbstractAttributeMap.this.containsValue(o);
+        }
+
+        public boolean remove(Object o)
+        {
+            if (o == null)
+            {
+                return false;
+            }
+
+            for (Iterator it = iterator(); it.hasNext();)
+            {
+                if (o.equals(it.next()))
+                {
+                    it.remove();
+                    return true;
+                }
+            }
+
+            return false;
+        }
+    }
+
+    private class ValuesIterator extends KeyIterator
+    {
+        public Object next()
+        {
+            super.next();
+            return AbstractAttributeMap.this.get(_currentKey);
+        }
+    }
+
+    private class EntrySet extends KeySet
+    {
+        public Iterator iterator() {
+            return new EntryIterator();
+        }
+
+        public boolean contains(Object o) {
+            if (!(o instanceof Entry))
+            {
+                return false;
+            }
+
+            Entry entry = (Entry) o;
+            Object key = entry.getKey();
+            Object value = entry.getValue();
+            if (key == null || value == null)
+            {
+                return false;
+            }
+
+            return value.equals(AbstractAttributeMap.this.get(key));
+        }
+
+        public boolean remove(Object o) {
+            if (!(o instanceof Entry))
+            {
+                return false;
+            }
+
+            Entry entry = (Entry) o;
+            Object key = entry.getKey();
+            Object value = entry.getValue();
+            if (key == null || value == null
+                || !value.equals(AbstractAttributeMap.this.get(key)))
+            {
+                return false;
+            }
+
+            return AbstractAttributeMap.this.remove(((Entry) o).getKey()) != null;
+        }
+    }
+
+    /**
+     * Not very efficient since it generates a new instance of <code>Entry</code>
+     * for each element and still internaly uses the <code>KeyIterator</code>.
+     * It is more efficient to use the <code>KeyIterator</code> directly.
+     */
+    private class EntryIterator extends KeyIterator
+    {
+        public Object next()
+        {
+            super.next();
+            // Must create new Entry every time--value of the entry must stay
+            // linked to the same attribute name
+            return new EntrySetEntry(_currentKey);
+        }
+    }
+
+    private class EntrySetEntry implements Entry
+    {
+        private final Object _currentKey;
+
+        public EntrySetEntry(Object currentKey)
+        {
+            _currentKey = currentKey;
+        }
+
+        public Object getKey()
+        {
+            return _currentKey;
+        }
+
+        public Object getValue()
+        {
+            return AbstractAttributeMap.this.get(_currentKey);
+        }
+
+        public Object setValue(Object value)
+        {
+            return AbstractAttributeMap.this.put(_currentKey, value);
+        }
+
+        public int hashCode() {
+            return _currentKey == null ? 0 : _currentKey.hashCode();
+        }
+
+        public boolean equals(Object obj) {
+            if (!(obj instanceof EntrySetEntry))
+                return false;
+            return _currentKey != null && _currentKey.equals(obj);
+        }
+    }
+}

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/AbstractAttributeMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/AbstractAttributeMap.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/CookieMap.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/CookieMap.java?rev=669711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/CookieMap.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/CookieMap.java Thu Jun 19 14:49:59 2008
@@ -0,0 +1,166 @@
+/*
+ * 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.myfaces.webapp.filter.servlet;
+
+import java.util.Enumeration;
+import java.util.Map;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * HttpServletRequest Cookies as Map.
+ *
+ * @author Dimitry D'hondt
+ * @author Anton Koinov
+ * @version $Revision$ $Date$
+ */
+public class CookieMap extends AbstractAttributeMap
+{
+    private static final Cookie[] EMPTY_ARRAY = new Cookie[0];
+
+    final HttpServletRequest _httpServletRequest;
+
+    CookieMap(HttpServletRequest httpServletRequest)
+    {
+        _httpServletRequest = httpServletRequest;
+    }
+
+    public void clear()
+    {
+        throw new UnsupportedOperationException(
+            "Cannot clear HttpRequest Cookies");
+    }
+
+    public boolean containsKey(Object key)
+    {
+        Cookie[] cookies = _httpServletRequest.getCookies();
+        if (cookies == null) return false;
+        for (int i = 0, len = cookies.length; i < len; i++)
+        {
+            if (cookies[i].getName().equals(key))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public boolean containsValue(Object findValue)
+    {
+        if (findValue == null)
+        {
+            return false;
+        }
+
+        Cookie[] cookies = _httpServletRequest.getCookies();
+        if (cookies == null) return false;
+        for (int i = 0, len = cookies.length; i < len; i++)
+        {
+            if (findValue.equals(cookies[i]))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public boolean isEmpty()
+    {
+        Cookie[] cookies = _httpServletRequest.getCookies();
+        return cookies == null || cookies.length == 0;
+    }
+
+    public int size()
+    {
+        Cookie[] cookies = _httpServletRequest.getCookies();
+        return cookies == null ? 0 : cookies.length;
+    }
+
+    public void putAll(Map t)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    protected Object getAttribute(String key)
+    {
+        Cookie[] cookies = _httpServletRequest.getCookies();
+        if (cookies == null) return null;
+        for (int i = 0, len = cookies.length; i < len; i++)
+        {
+            if (cookies[i].getName().equals(key))
+            {
+                return cookies[i];
+            }
+        }
+
+        return null;
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot set HttpRequest Cookies");
+    }
+
+    protected void removeAttribute(String key)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot remove HttpRequest Cookies");
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        Cookie[] cookies = _httpServletRequest.getCookies();
+        if (cookies == null)
+        {
+            return new CookieNameEnumeration(EMPTY_ARRAY);
+        }
+        else
+        {
+            return new CookieNameEnumeration(cookies);
+        }
+    }
+
+    private static class CookieNameEnumeration implements Enumeration
+    {
+        private final Cookie[] _cookies;
+        private final int _length;
+        private int _index;
+
+        public CookieNameEnumeration(Cookie[] cookies)
+        {
+            _cookies = cookies;
+            _length = cookies.length;
+        }
+
+        public boolean hasMoreElements()
+        {
+            return _index < _length;
+        }
+
+        public Object nextElement()
+        {
+            return _cookies[_index++].getName();
+        }
+    }
+}

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/CookieMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/CookieMap.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestHeaderMap.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestHeaderMap.java?rev=669711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestHeaderMap.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestHeaderMap.java Thu Jun 19 14:49:59 2008
@@ -0,0 +1,74 @@
+/*
+ * 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.myfaces.webapp.filter.servlet;
+
+import java.util.Enumeration;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * HttpServletRequest headers as Map.
+ * 
+ * @author Anton Koinov (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class RequestHeaderMap extends AbstractAttributeMap
+{
+    private final HttpServletRequest _httpServletRequest;
+
+    RequestHeaderMap(HttpServletRequest httpServletRequest)
+    {
+        _httpServletRequest = httpServletRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        return _httpServletRequest.getHeader(key);
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot set HttpServletRequest Header");
+    }
+
+    protected void removeAttribute(String key)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot remove HttpServletRequest Header");
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _httpServletRequest.getHeaderNames();
+    }
+
+    public void putAll(Map t)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public void clear()
+    {
+        throw new UnsupportedOperationException();
+    }    
+}

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestHeaderMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestHeaderMap.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestHeaderValuesMap.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestHeaderValuesMap.java?rev=669711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestHeaderValuesMap.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestHeaderValuesMap.java Thu Jun 19 14:49:59 2008
@@ -0,0 +1,86 @@
+/*
+ * 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.myfaces.webapp.filter.servlet;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * HttpServletRequest header values (multi-value headers) as Map of String[].
+ * 
+ * @author Anton Koinov (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class RequestHeaderValuesMap extends AbstractAttributeMap
+{
+    private final HttpServletRequest _httpServletRequest;
+    private final Map                _valueCache = new HashMap();
+
+    RequestHeaderValuesMap(HttpServletRequest httpServletRequest)
+    {
+        _httpServletRequest = httpServletRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        Object ret = _valueCache.get(key);
+        if (ret == null)
+        {
+            _valueCache.put(key, ret = toArray(_httpServletRequest
+                .getHeaders(key)));
+        }
+
+        return ret;
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot set HttpServletRequest HeaderValues");
+    }
+
+    protected void removeAttribute(String key)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot remove HttpServletRequest HeaderValues");
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _httpServletRequest.getHeaderNames();
+    }
+
+    private String[] toArray(Enumeration e)
+    {
+        List ret = new ArrayList();
+
+        while (e.hasMoreElements())
+        {
+            ret.add(e.nextElement());
+        }
+
+        return (String[]) ret.toArray(new String[ret.size()]);
+    }
+}
\ No newline at end of file

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestHeaderValuesMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestHeaderValuesMap.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestMap.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestMap.java?rev=669711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestMap.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestMap.java Thu Jun 19 14:49:59 2008
@@ -0,0 +1,72 @@
+/*
+ * 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.myfaces.webapp.filter.servlet;
+
+import java.util.Enumeration;
+import java.util.Map;
+
+import javax.servlet.ServletRequest;
+
+
+/**
+ * ServletRequest attributes Map.
+ * 
+ * @author Anton Koinov (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class RequestMap extends AbstractAttributeMap
+{
+    final ServletRequest _servletRequest;
+
+    RequestMap(ServletRequest servletRequest)
+    {
+        _servletRequest = servletRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        return _servletRequest.getAttribute(key);
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        _servletRequest.setAttribute(key, value);
+    }
+
+    protected void removeAttribute(String key)
+    {
+        _servletRequest.removeAttribute(key);
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _servletRequest.getAttributeNames();
+    }
+
+    public void putAll(Map t)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public void clear()
+    {
+        throw new UnsupportedOperationException();
+    }    
+}

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestMap.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestParameterMap.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestParameterMap.java?rev=669711&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestParameterMap.java (added)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/webapp/filter/servlet/RequestParameterMap.java Thu Jun 19 14:49:59 2008
@@ -0,0 +1,61 @@
+/*
+ * 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.myfaces.webapp.filter.servlet;
+
+import java.util.Enumeration;
+
+import javax.servlet.ServletRequest;
+
+/**
+ * ServletRequest parameters as Map.
+ * 
+ * @author Anton Koinov (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class RequestParameterMap extends AbstractAttributeMap
+{
+    private final ServletRequest _servletRequest;
+
+    RequestParameterMap(ServletRequest servletRequest)
+    {
+        _servletRequest = servletRequest;
+    }
+
+    protected Object getAttribute(String key)
+    {
+        return _servletRequest.getParameter(key);
+    }
+
+    protected void setAttribute(String key, Object value)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot set ServletRequest Parameter");
+    }
+
+    protected void removeAttribute(String key)
+    {
+        throw new UnsupportedOperationException(
+            "Cannot remove ServletRequest Parameter");
+    }
+
+    protected Enumeration getAttributeNames()
+    {
+        return _servletRequest.getParameterNames();
+    }
+}
\ No newline at end of file