You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by so...@apache.org on 2007/11/19 17:56:32 UTC

svn commit: r596365 [1/5] - in /myfaces/portlet-bridge/trunk: api/src/main/java/javax/portlet/faces/ api/src/main/java/javax/portlet/faces/component/ impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ impl/src/main/java/org/apache/myfa...

Author: sobryan
Date: Mon Nov 19 08:56:29 2007
New Revision: 596365

URL: http://svn.apache.org/viewvc?rev=596365&view=rev
Log:
Made all files use consistant formatting for CR/LF.  Although svn will
will handle this based on the system checking in the code, some of this
code came from a windows environment but was checked in using my unix
environment.  Therefore the CR/LF's are incorrectly handled.

Modified:
    myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/BridgeDefaultViewNotSpecifiedException.java
    myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/BridgeException.java
    myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
    myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionRequestDecorator.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionResponseDecorator.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/BridgeRenderRequestWrapper.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/PortletRequestDecorator.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/PortletResponseDecorator.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/RenderRequestDecorator.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesContextFactoryImpl.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/el/PortletELContextImpl.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/HTTPUtils.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/QueryString.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/SimpleStringBuffer.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/TextUtils.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/URLUtils.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/LocalesIterator.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletAbstractMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletApplicationMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletInitParameterMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaderValuesMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestParameterValuesMap.java
    myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletSessionMap.java

Modified: myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/BridgeDefaultViewNotSpecifiedException.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/BridgeDefaultViewNotSpecifiedException.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/BridgeDefaultViewNotSpecifiedException.java (original)
+++ myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/BridgeDefaultViewNotSpecifiedException.java Mon Nov 19 08:56:29 2007
@@ -1,37 +1,37 @@
-/*
- * 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 javax.portlet.faces;
-
-public class BridgeDefaultViewNotSpecifiedException extends BridgeException
-{
-  //TODO: This should be regenerated each time this is modified.  Can this be added to maven?
-  private static final long serialVersionUID = 540438273186022660L;
-
-  public BridgeDefaultViewNotSpecifiedException()
-  {
-    super();
-  }
-
-  public BridgeDefaultViewNotSpecifiedException(String message)
-  {
-    super(message);
-  }
-
-  public BridgeDefaultViewNotSpecifiedException(String message, Throwable cause)
-  {
-    super(message, cause);
-  }
-
-  public BridgeDefaultViewNotSpecifiedException(Throwable cause)
-  {
-    super(cause);
-  }
-}
+/*
+ * 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 javax.portlet.faces;
+
+public class BridgeDefaultViewNotSpecifiedException extends BridgeException
+{
+  //TODO: This should be regenerated each time this is modified.  Can this be added to maven?
+  private static final long serialVersionUID = 540438273186022660L;
+
+  public BridgeDefaultViewNotSpecifiedException()
+  {
+    super();
+  }
+
+  public BridgeDefaultViewNotSpecifiedException(String message)
+  {
+    super(message);
+  }
+
+  public BridgeDefaultViewNotSpecifiedException(String message, Throwable cause)
+  {
+    super(message, cause);
+  }
+
+  public BridgeDefaultViewNotSpecifiedException(Throwable cause)
+  {
+    super(cause);
+  }
+}

Modified: myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/BridgeException.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/BridgeException.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/BridgeException.java (original)
+++ myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/BridgeException.java Mon Nov 19 08:56:29 2007
@@ -1,39 +1,39 @@
-/*
- * 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 javax.portlet.faces;
-
-import javax.faces.FacesException;
-
-public class BridgeException extends FacesException
-{
-  //TODO: This should be regenerated each time this is modified.  Can this be added to maven?
-  private static final long serialVersionUID = 6758659847475864393L;
-
-  public BridgeException()
-  {
-    super();
-  }
-
-  public BridgeException(String message)
-  {
-    super(message);
-  }
-
-  public BridgeException(String message, Throwable cause)
-  {
-    super(message, cause);
-  }
-
-  public BridgeException(Throwable cause)
-  {
-    super(cause);
-  }
-}
+/*
+ * 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 javax.portlet.faces;
+
+import javax.faces.FacesException;
+
+public class BridgeException extends FacesException
+{
+  //TODO: This should be regenerated each time this is modified.  Can this be added to maven?
+  private static final long serialVersionUID = 6758659847475864393L;
+
+  public BridgeException()
+  {
+    super();
+  }
+
+  public BridgeException(String message)
+  {
+    super(message);
+  }
+
+  public BridgeException(String message, Throwable cause)
+  {
+    super(message, cause);
+  }
+
+  public BridgeException(Throwable cause)
+  {
+    super(cause);
+  }
+}

Modified: myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java (original)
+++ myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java Mon Nov 19 08:56:29 2007
@@ -1,384 +1,384 @@
-/*
- * 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 javax.portlet.faces;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-
-import javax.portlet.ActionRequest;
-import javax.portlet.ActionResponse;
-import javax.portlet.GenericPortlet;
-import javax.portlet.PortletConfig;
-import javax.portlet.PortletContext;
-import javax.portlet.PortletException;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletRequest;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.portlet.WindowState;
-
-/**
- * The <code>GenericFacesPortlet</code> is provided to simplify development of a portlet that in
- * whole or part relies on the Faces bridge to process requests. If all requests are to be handled
- * by the bridge, <code>GenericFacesPortlet</code> is a turnkey implementation. Developers do not
- * need to subclass it. However, if there are some situations where the portlet doesn't require
- * bridge services then <code>GenericFacesPortlet</code> can be subclassed and overriden.
- * <p>
- * Since <code>GenericFacesPortlet</code> subclasses <code>GenericPortlet</code> care is taken
- * to all subclasses to override naturally. For example, though <code>doDispatch()</code> is
- * overriden, requests are only dispatched to the bridge from here if the <code>PortletMode</code>
- * isn't <code>VIEW</code>, <code>EDIT</code>, or <code>HELP</code>.
- * <p>
- * The <code>GenericFacesPortlet</code> recognizes the following portlet init parameters:
- * <ul>
- * <li><code>javax.portlet.faces.defaultViewId.[<i>mode</i>]</code>: specifies on a per mode
- * basis the default viewId the Bridge executes when not already encoded in the incoming request. A
- * value must be defined for each <code>PortletMode</code> the <code>Bridge</code> is expected
- * to process. </li>
- * </ul>
- * The <code>GenericFacesPortlet</code> recognizes the following <code>
- * PortletContext</code>
- * init parameters:
- * <ul>
- * <li><code>javax.portlet.faces.BridgeImplClass</code>: specifies the <code>Bridge</code>implementation
- * class used by this portlet. This init parameter must be specified or else an exception is thrown.
- * </li>
- * </ul>
- */
-public class GenericFacesPortlet extends GenericPortlet
-{
-  public static final String BRIDGE_CLASS             = Bridge.BRIDGE_PACKAGE_PREFIX
-                                                        + "BridgeImplClass";
-  public static final String BRIDGE_SERVICE_CLASSPATH = "/META-INF/services/javax.portlet.faces.Bridge";
-
-  private Class              mFacesBridgeClass        = null;
-  private Bridge             mFacesBridge             = null;
-
-  /**
-   * Initialize generic faces portlet from portlet.xml
-   */
-  @Override
-  public void init(PortletConfig portletConfig) throws PortletException
-  {
-    super.init(portletConfig);
-
-    // Make sure the bridge impl class is defined -- if not then search for it
-    // using same search rules as Faces
-    String bridgeClassName = getBridgeClassName();
-
-    if (bridgeClassName != null)
-    {
-      try
-      {
-        mFacesBridgeClass = Thread.currentThread().getContextClassLoader().loadClass(bridgeClassName);
-      }
-      catch (ClassNotFoundException cnfe)
-      {
-        // Do nothing and fall through to null check
-      }
-    }
-
-    if (mFacesBridgeClass == null)
-    {
-      throw new PortletException("Configuration Error: Initial Parameter '" + BRIDGE_CLASS
-                                 + "' is not defined for portlet: " + getPortletName());
-    }
-
-    // Context level attribute for whether to encode redirect URL
-    String renderPolicy = getPortletConfig().getInitParameter(
-                                                              Bridge.BRIDGE_PACKAGE_PREFIX
-                                                                  + Bridge.RENDER_POLICY);
-    if (renderPolicy != null)
-    {
-      getPortletContext().setAttribute(
-                                       Bridge.BRIDGE_PACKAGE_PREFIX + getPortletName() + "."
-                                           + Bridge.RENDER_POLICY,
-                                       Bridge.BridgeRenderPolicy.valueOf(renderPolicy));
-    }
-    String preserveActionParams = getPortletConfig()
-                                                    .getInitParameter(
-                                                                      Bridge.BRIDGE_PACKAGE_PREFIX
-                                                                          + Bridge.PRESERVE_ACTION_PARAMS);
-    if (preserveActionParams != null)
-    {
-      getPortletContext().setAttribute(
-                                       Bridge.BRIDGE_PACKAGE_PREFIX + getPortletName() + "."
-                                           + Bridge.PRESERVE_ACTION_PARAMS,
-                                       Boolean.valueOf(preserveActionParams));
-    }
-
-    // Don't instanciate/initialize the bridge yet. Do it on first use
-  }
-
-  /**
-   * Release resources
-   */
-  @Override
-  public void destroy()
-  {
-    if (mFacesBridge != null)
-    {
-      mFacesBridge.destroy();
-      mFacesBridge = null;
-      mFacesBridgeClass = null;
-    }
-  }
-
-  /**
-   * If mode is VIEW, EDIT, or HELP -- defer to the doView, doEdit, doHelp so subclasses can
-   * override. Otherwise handle mode here if there is a defaultViewId mapping for it.
-   */
-  @Override
-  public void doDispatch(RenderRequest request, RenderResponse response) throws PortletException,
-                                                                        IOException
-  {
-    // Defer to helper methods for standard modes so subclasses can override
-    PortletMode mode = request.getPortletMode();
-    if (mode == PortletMode.EDIT || mode == PortletMode.HELP || mode == PortletMode.VIEW)
-    {
-      super.doDispatch(request, response);
-    }
-    else
-    {
-      doDispatchInternal(request, response, request.getPortletMode());
-    }
-  }
-
-  @Override
-  protected void doEdit(RenderRequest request, RenderResponse response) throws PortletException,
-                                                                       java.io.IOException
-  {
-    doDispatchInternal(request, response, request.getPortletMode());
-
-  }
-
-  @Override
-  protected void doHelp(RenderRequest request, RenderResponse response) throws PortletException,
-                                                                       java.io.IOException
-  {
-    doDispatchInternal(request, response, request.getPortletMode());
-
-  }
-
-  @Override
-  protected void doView(RenderRequest request, RenderResponse response) throws PortletException,
-                                                                       java.io.IOException
-  {
-    doDispatchInternal(request, response, request.getPortletMode());
-
-  }
-
-  @Override
-  public void processAction(ActionRequest request, ActionResponse response)
-                                                                           throws PortletException,
-                                                                           IOException
-  {
-    doBridgeDispatch(request, response, getDefaultViewId(request, request.getPortletMode()));
-  }
-
-  /**
-   * Returns the className of the bridge implementation this portlet uses. Subclasses override to
-   * alter the default behavior. Default implementation first checks for a portlet context init
-   * parameter: javax.portlet.faces.BridgeImplClass. If it doesn't exist then it looks for the
-   * resource file "/META-INF/services/javax.portlet.faces.Bridge" using the current threads
-   * classloader and extracts the classname from the first line in that file.
-   * 
-   * @return the class name of the Bridge class the GenericFacesPortlet uses. null if it can't be
-   *         determined.
-   */
-  public String getBridgeClassName()
-  {
-    String bridgeClassName = getPortletConfig().getPortletContext().getInitParameter(BRIDGE_CLASS);
-
-    if (bridgeClassName == null)
-    {
-      bridgeClassName = getFromServicesPath(getPortletConfig().getPortletContext(),
-                                            BRIDGE_SERVICE_CLASSPATH);
-    }
-    return bridgeClassName;
-  }
-
-  /**
-   * Returns the defaultViewId to be used for this request. The defaultViewId is depends on the
-   * PortletMode.
-   * 
-   * @param request
-   *          the request object.
-   * @param mode
-   *          the mode which to return the defaultViewId for.
-   * @return the defaultViewId for this mode
-   */
-  public String getDefaultViewId(PortletRequest request, PortletMode mode)
-  {
-    return getPortletConfig().getInitParameter(Bridge.DEFAULT_VIEWID + "." + mode.toString());
-  }
-
-  private void doDispatchInternal(RenderRequest request, RenderResponse response, PortletMode mode)
-                                                                                                   throws PortletException,
-                                                                                                   IOException
-  {
-    // Only process if there is a default page defined for this mode
-    String modeDefaultViewId = getDefaultViewId(request, mode);
-
-    if (!(modeDefaultViewId == null))
-    {
-      WindowState state = request.getWindowState();
-      if (!state.equals(WindowState.MINIMIZED))
-      {
-        doBridgeDispatch(request, response, modeDefaultViewId);
-      }
-    }
-    else
-    {
-      super.doDispatch(request, response);
-    }
-  }
-
-  private void doBridgeDispatch(RenderRequest request, RenderResponse response, String defaultViewId)
-                                                                                                     throws PortletException
-  {
-    // initial Bridge if not already active
-    initBridge();
-    // Push information for Bridge into request attributes
-    setBridgeRequestContext(request, defaultViewId);
-    try
-    {
-      mFacesBridge.doFacesRequest(request, response);
-    }
-    catch (BridgeException e)
-    {
-      throw new PortletException(
-                                 "doBridgeDispatch failed:  error from Bridge in executing the request",
-                                 e);
-    }
-
-  }
-
-  private void doBridgeDispatch(ActionRequest request, ActionResponse response, String defaultViewId)
-                                                                                                     throws PortletException
-  {
-    // initial Bridge if not already active
-    initBridge();
-    // Push information for Bridge into request attributes
-    setBridgeRequestContext(request, defaultViewId);
-    try
-    {
-      mFacesBridge.doFacesRequest(request, response);
-    }
-    catch (BridgeException e)
-    {
-      throw new PortletException(
-                                 "doBridgeDispatch failed:  error from Bridge in executing the request",
-                                 e);
-    }
-
-  }
-
-  private void initBridge() throws PortletException
-  {
-    if (mFacesBridge == null)
-    {
-      try
-      {
-        mFacesBridge = (Bridge) mFacesBridgeClass.newInstance();
-        mFacesBridge.init(getPortletConfig());
-      }
-      catch (Exception e)
-      {
-        throw new PortletException("doBridgeDisptach:  error instantiating the bridge class", e);
-      }
-    }
-  }
-
-  private void setBridgeRequestContext(PortletRequest request, String defaultViewId)
-  {
-    // Make the defaultViewId available to the Bridge
-    request.setAttribute(Bridge.DEFAULT_VIEWID, defaultViewId);
-  }
-
-  private String getFromServicesPath(PortletContext context, String resourceName)
-  {
-    // Check for a services definition
-    String result = null;
-    BufferedReader reader = null;
-    InputStream stream = null;
-    try
-    {
-      ClassLoader cl = Thread.currentThread().getContextClassLoader();
-      if (cl == null)
-      {
-        return null;
-      }
-
-      stream = cl.getResourceAsStream(resourceName);
-      if (stream != null)
-      {
-        // Deal with systems whose native encoding is possibly
-        // different from the way that the services entry was created
-        try
-        {
-          reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
-        }
-        catch (UnsupportedEncodingException e)
-        {
-          reader = new BufferedReader(new InputStreamReader(stream));
-        }
-        result = reader.readLine();
-        if (result != null)
-        {
-          result = result.trim();
-        }
-        reader.close();
-        reader = null;
-        stream = null;
-      }
-    }
-    catch (IOException e)
-    {
-    }
-    catch (SecurityException e)
-    {
-    }
-    finally
-    {
-      if (reader != null)
-      {
-        try
-        {
-          reader.close();
-          stream = null;
-        }
-        catch (Throwable t)
-        {
-          ;
-        }
-        reader = null;
-      }
-      if (stream != null)
-      {
-        try
-        {
-          stream.close();
-        }
-        catch (Throwable t)
-        {
-          ;
-        }
-        stream = null;
-      }
-    }
-    return result;
-  }
-
-}
+/*
+ * 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 javax.portlet.faces;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletRequest;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.WindowState;
+
+/**
+ * The <code>GenericFacesPortlet</code> is provided to simplify development of a portlet that in
+ * whole or part relies on the Faces bridge to process requests. If all requests are to be handled
+ * by the bridge, <code>GenericFacesPortlet</code> is a turnkey implementation. Developers do not
+ * need to subclass it. However, if there are some situations where the portlet doesn't require
+ * bridge services then <code>GenericFacesPortlet</code> can be subclassed and overriden.
+ * <p>
+ * Since <code>GenericFacesPortlet</code> subclasses <code>GenericPortlet</code> care is taken
+ * to all subclasses to override naturally. For example, though <code>doDispatch()</code> is
+ * overriden, requests are only dispatched to the bridge from here if the <code>PortletMode</code>
+ * isn't <code>VIEW</code>, <code>EDIT</code>, or <code>HELP</code>.
+ * <p>
+ * The <code>GenericFacesPortlet</code> recognizes the following portlet init parameters:
+ * <ul>
+ * <li><code>javax.portlet.faces.defaultViewId.[<i>mode</i>]</code>: specifies on a per mode
+ * basis the default viewId the Bridge executes when not already encoded in the incoming request. A
+ * value must be defined for each <code>PortletMode</code> the <code>Bridge</code> is expected
+ * to process. </li>
+ * </ul>
+ * The <code>GenericFacesPortlet</code> recognizes the following <code>
+ * PortletContext</code>
+ * init parameters:
+ * <ul>
+ * <li><code>javax.portlet.faces.BridgeImplClass</code>: specifies the <code>Bridge</code>implementation
+ * class used by this portlet. This init parameter must be specified or else an exception is thrown.
+ * </li>
+ * </ul>
+ */
+public class GenericFacesPortlet extends GenericPortlet
+{
+  public static final String BRIDGE_CLASS             = Bridge.BRIDGE_PACKAGE_PREFIX
+                                                        + "BridgeImplClass";
+  public static final String BRIDGE_SERVICE_CLASSPATH = "/META-INF/services/javax.portlet.faces.Bridge";
+
+  private Class              mFacesBridgeClass        = null;
+  private Bridge             mFacesBridge             = null;
+
+  /**
+   * Initialize generic faces portlet from portlet.xml
+   */
+  @Override
+  public void init(PortletConfig portletConfig) throws PortletException
+  {
+    super.init(portletConfig);
+
+    // Make sure the bridge impl class is defined -- if not then search for it
+    // using same search rules as Faces
+    String bridgeClassName = getBridgeClassName();
+
+    if (bridgeClassName != null)
+    {
+      try
+      {
+        mFacesBridgeClass = Thread.currentThread().getContextClassLoader().loadClass(bridgeClassName);
+      }
+      catch (ClassNotFoundException cnfe)
+      {
+        // Do nothing and fall through to null check
+      }
+    }
+
+    if (mFacesBridgeClass == null)
+    {
+      throw new PortletException("Configuration Error: Initial Parameter '" + BRIDGE_CLASS
+                                 + "' is not defined for portlet: " + getPortletName());
+    }
+
+    // Context level attribute for whether to encode redirect URL
+    String renderPolicy = getPortletConfig().getInitParameter(
+                                                              Bridge.BRIDGE_PACKAGE_PREFIX
+                                                                  + Bridge.RENDER_POLICY);
+    if (renderPolicy != null)
+    {
+      getPortletContext().setAttribute(
+                                       Bridge.BRIDGE_PACKAGE_PREFIX + getPortletName() + "."
+                                           + Bridge.RENDER_POLICY,
+                                       Bridge.BridgeRenderPolicy.valueOf(renderPolicy));
+    }
+    String preserveActionParams = getPortletConfig()
+                                                    .getInitParameter(
+                                                                      Bridge.BRIDGE_PACKAGE_PREFIX
+                                                                          + Bridge.PRESERVE_ACTION_PARAMS);
+    if (preserveActionParams != null)
+    {
+      getPortletContext().setAttribute(
+                                       Bridge.BRIDGE_PACKAGE_PREFIX + getPortletName() + "."
+                                           + Bridge.PRESERVE_ACTION_PARAMS,
+                                       Boolean.valueOf(preserveActionParams));
+    }
+
+    // Don't instanciate/initialize the bridge yet. Do it on first use
+  }
+
+  /**
+   * Release resources
+   */
+  @Override
+  public void destroy()
+  {
+    if (mFacesBridge != null)
+    {
+      mFacesBridge.destroy();
+      mFacesBridge = null;
+      mFacesBridgeClass = null;
+    }
+  }
+
+  /**
+   * If mode is VIEW, EDIT, or HELP -- defer to the doView, doEdit, doHelp so subclasses can
+   * override. Otherwise handle mode here if there is a defaultViewId mapping for it.
+   */
+  @Override
+  public void doDispatch(RenderRequest request, RenderResponse response) throws PortletException,
+                                                                        IOException
+  {
+    // Defer to helper methods for standard modes so subclasses can override
+    PortletMode mode = request.getPortletMode();
+    if (mode == PortletMode.EDIT || mode == PortletMode.HELP || mode == PortletMode.VIEW)
+    {
+      super.doDispatch(request, response);
+    }
+    else
+    {
+      doDispatchInternal(request, response, request.getPortletMode());
+    }
+  }
+
+  @Override
+  protected void doEdit(RenderRequest request, RenderResponse response) throws PortletException,
+                                                                       java.io.IOException
+  {
+    doDispatchInternal(request, response, request.getPortletMode());
+
+  }
+
+  @Override
+  protected void doHelp(RenderRequest request, RenderResponse response) throws PortletException,
+                                                                       java.io.IOException
+  {
+    doDispatchInternal(request, response, request.getPortletMode());
+
+  }
+
+  @Override
+  protected void doView(RenderRequest request, RenderResponse response) throws PortletException,
+                                                                       java.io.IOException
+  {
+    doDispatchInternal(request, response, request.getPortletMode());
+
+  }
+
+  @Override
+  public void processAction(ActionRequest request, ActionResponse response)
+                                                                           throws PortletException,
+                                                                           IOException
+  {
+    doBridgeDispatch(request, response, getDefaultViewId(request, request.getPortletMode()));
+  }
+
+  /**
+   * Returns the className of the bridge implementation this portlet uses. Subclasses override to
+   * alter the default behavior. Default implementation first checks for a portlet context init
+   * parameter: javax.portlet.faces.BridgeImplClass. If it doesn't exist then it looks for the
+   * resource file "/META-INF/services/javax.portlet.faces.Bridge" using the current threads
+   * classloader and extracts the classname from the first line in that file.
+   * 
+   * @return the class name of the Bridge class the GenericFacesPortlet uses. null if it can't be
+   *         determined.
+   */
+  public String getBridgeClassName()
+  {
+    String bridgeClassName = getPortletConfig().getPortletContext().getInitParameter(BRIDGE_CLASS);
+
+    if (bridgeClassName == null)
+    {
+      bridgeClassName = getFromServicesPath(getPortletConfig().getPortletContext(),
+                                            BRIDGE_SERVICE_CLASSPATH);
+    }
+    return bridgeClassName;
+  }
+
+  /**
+   * Returns the defaultViewId to be used for this request. The defaultViewId is depends on the
+   * PortletMode.
+   * 
+   * @param request
+   *          the request object.
+   * @param mode
+   *          the mode which to return the defaultViewId for.
+   * @return the defaultViewId for this mode
+   */
+  public String getDefaultViewId(PortletRequest request, PortletMode mode)
+  {
+    return getPortletConfig().getInitParameter(Bridge.DEFAULT_VIEWID + "." + mode.toString());
+  }
+
+  private void doDispatchInternal(RenderRequest request, RenderResponse response, PortletMode mode)
+                                                                                                   throws PortletException,
+                                                                                                   IOException
+  {
+    // Only process if there is a default page defined for this mode
+    String modeDefaultViewId = getDefaultViewId(request, mode);
+
+    if (!(modeDefaultViewId == null))
+    {
+      WindowState state = request.getWindowState();
+      if (!state.equals(WindowState.MINIMIZED))
+      {
+        doBridgeDispatch(request, response, modeDefaultViewId);
+      }
+    }
+    else
+    {
+      super.doDispatch(request, response);
+    }
+  }
+
+  private void doBridgeDispatch(RenderRequest request, RenderResponse response, String defaultViewId)
+                                                                                                     throws PortletException
+  {
+    // initial Bridge if not already active
+    initBridge();
+    // Push information for Bridge into request attributes
+    setBridgeRequestContext(request, defaultViewId);
+    try
+    {
+      mFacesBridge.doFacesRequest(request, response);
+    }
+    catch (BridgeException e)
+    {
+      throw new PortletException(
+                                 "doBridgeDispatch failed:  error from Bridge in executing the request",
+                                 e);
+    }
+
+  }
+
+  private void doBridgeDispatch(ActionRequest request, ActionResponse response, String defaultViewId)
+                                                                                                     throws PortletException
+  {
+    // initial Bridge if not already active
+    initBridge();
+    // Push information for Bridge into request attributes
+    setBridgeRequestContext(request, defaultViewId);
+    try
+    {
+      mFacesBridge.doFacesRequest(request, response);
+    }
+    catch (BridgeException e)
+    {
+      throw new PortletException(
+                                 "doBridgeDispatch failed:  error from Bridge in executing the request",
+                                 e);
+    }
+
+  }
+
+  private void initBridge() throws PortletException
+  {
+    if (mFacesBridge == null)
+    {
+      try
+      {
+        mFacesBridge = (Bridge) mFacesBridgeClass.newInstance();
+        mFacesBridge.init(getPortletConfig());
+      }
+      catch (Exception e)
+      {
+        throw new PortletException("doBridgeDisptach:  error instantiating the bridge class", e);
+      }
+    }
+  }
+
+  private void setBridgeRequestContext(PortletRequest request, String defaultViewId)
+  {
+    // Make the defaultViewId available to the Bridge
+    request.setAttribute(Bridge.DEFAULT_VIEWID, defaultViewId);
+  }
+
+  private String getFromServicesPath(PortletContext context, String resourceName)
+  {
+    // Check for a services definition
+    String result = null;
+    BufferedReader reader = null;
+    InputStream stream = null;
+    try
+    {
+      ClassLoader cl = Thread.currentThread().getContextClassLoader();
+      if (cl == null)
+      {
+        return null;
+      }
+
+      stream = cl.getResourceAsStream(resourceName);
+      if (stream != null)
+      {
+        // Deal with systems whose native encoding is possibly
+        // different from the way that the services entry was created
+        try
+        {
+          reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
+        }
+        catch (UnsupportedEncodingException e)
+        {
+          reader = new BufferedReader(new InputStreamReader(stream));
+        }
+        result = reader.readLine();
+        if (result != null)
+        {
+          result = result.trim();
+        }
+        reader.close();
+        reader = null;
+        stream = null;
+      }
+    }
+    catch (IOException e)
+    {
+    }
+    catch (SecurityException e)
+    {
+    }
+    finally
+    {
+      if (reader != null)
+      {
+        try
+        {
+          reader.close();
+          stream = null;
+        }
+        catch (Throwable t)
+        {
+          ;
+        }
+        reader = null;
+      }
+      if (stream != null)
+      {
+        try
+        {
+          stream.close();
+        }
+        catch (Throwable t)
+        {
+          ;
+        }
+        stream = null;
+      }
+    }
+    return result;
+  }
+
+}

Modified: myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java (original)
+++ myfaces/portlet-bridge/trunk/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java Mon Nov 19 08:56:29 2007
@@ -1,86 +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 javax.portlet.faces.component;
-
-import java.io.Serializable;
-
-import javax.faces.context.FacesContext;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-
-/**
- * Bridge ViewRoot that implements NamingContainer which uses the ExternalContext.encodeNamespace to
- * introduce the consumer namespace into tree components.
- */
-public class PortletNamingContainerUIViewRoot extends UIViewRoot implements PortletNamingContainer,
-    Serializable
-{
-
-  //TODO: This should be regenerated each time this is modified.  Can this be added to maven?
-  private static final long   serialVersionUID = -4524288011655837711L;
-  private static final String SEPARATOR        = (new Character(NamingContainer.SEPARATOR_CHAR))
-                                                                                                .toString();
-
-  public PortletNamingContainerUIViewRoot()
-  {
-    super();
-  }
-
-  public PortletNamingContainerUIViewRoot(UIViewRoot viewRootToReplace)
-  {
-    super();
-    setViewId(viewRootToReplace.getViewId());
-    setLocale(viewRootToReplace.getLocale());
-    setRenderKitId(viewRootToReplace.getRenderKitId());
-  }
-
-  // Implement the method that satisfies NamingContainer
-
-  public static String getContainerClientId(FacesContext context, String additionalId)
-  {
-    ExternalContext ec = context.getExternalContext();
-    String namespace = ec.encodeNamespace(SEPARATOR);
-
-    /*
-     * In servlet world encodeNamespace does nothing -- so if we get back what we sent in then do
-     * not perturn the NamingContainer Id
-     */
-    if (namespace.length() > 1)
-    {
-      if (additionalId != null)
-      {
-        return namespace + additionalId;
-      }
-      else
-      {
-        return namespace;
-      }
-    }
-    else
-    {
-      return null;
-    }
-  }
-
-  // Implement the method that satisfies NamingContainer
-
-  @Override
-  public String getContainerClientId(FacesContext context)
-  {
-    return PortletNamingContainerUIViewRoot
-                                           .getContainerClientId(
-                                                                 context,
-                                                                 super
-                                                                      .getContainerClientId(context));
-  }
-
-}
+/*
+ * 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 javax.portlet.faces.component;
+
+import java.io.Serializable;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+
+/**
+ * Bridge ViewRoot that implements NamingContainer which uses the ExternalContext.encodeNamespace to
+ * introduce the consumer namespace into tree components.
+ */
+public class PortletNamingContainerUIViewRoot extends UIViewRoot implements PortletNamingContainer,
+    Serializable
+{
+
+  //TODO: This should be regenerated each time this is modified.  Can this be added to maven?
+  private static final long   serialVersionUID = -4524288011655837711L;
+  private static final String SEPARATOR        = (new Character(NamingContainer.SEPARATOR_CHAR))
+                                                                                                .toString();
+
+  public PortletNamingContainerUIViewRoot()
+  {
+    super();
+  }
+
+  public PortletNamingContainerUIViewRoot(UIViewRoot viewRootToReplace)
+  {
+    super();
+    setViewId(viewRootToReplace.getViewId());
+    setLocale(viewRootToReplace.getLocale());
+    setRenderKitId(viewRootToReplace.getRenderKitId());
+  }
+
+  // Implement the method that satisfies NamingContainer
+
+  public static String getContainerClientId(FacesContext context, String additionalId)
+  {
+    ExternalContext ec = context.getExternalContext();
+    String namespace = ec.encodeNamespace(SEPARATOR);
+
+    /*
+     * In servlet world encodeNamespace does nothing -- so if we get back what we sent in then do
+     * not perturn the NamingContainer Id
+     */
+    if (namespace.length() > 1)
+    {
+      if (additionalId != null)
+      {
+        return namespace + additionalId;
+      }
+      else
+      {
+        return namespace;
+      }
+    }
+    else
+    {
+      return null;
+    }
+  }
+
+  // Implement the method that satisfies NamingContainer
+
+  @Override
+  public String getContainerClientId(FacesContext context)
+  {
+    return PortletNamingContainerUIViewRoot
+                                           .getContainerClientId(
+                                                                 context,
+                                                                 super
+                                                                      .getContainerClientId(context));
+  }
+
+}

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionRequestDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionRequestDecorator.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionRequestDecorator.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionRequestDecorator.java Mon Nov 19 08:56:29 2007
@@ -1,148 +1,148 @@
-/* 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.portlet.faces.bridge.wrapper;
-
-import javax.portlet.ActionRequest;
-import javax.portlet.PortletRequest;
-
-public class ActionRequestDecorator extends PortletRequestDecorator implements ActionRequest
-{
-  private PortletRequest mRequest = null;
-
-  public ActionRequestDecorator(ActionRequest request) throws IllegalArgumentException
-  {
-
-    super(request);
-  }
-
-  /**
-   * Retrieves the body of the HTTP request from client to portal as binary data using an
-   * <CODE>InputStream</CODE>. Either this method or {@link #getReader} may be called to read the
-   * body, but not both.
-   * <p>
-   * For HTTP POST data of type application/x-www-form-urlencoded this method throws an
-   * <code>IllegalStateException</code> as this data has been already processed by the
-   * portal/portlet-container and is available as request parameters.
-   * 
-   * @return an input stream containing the body of the request
-   * 
-   * @exception java.lang.IllegalStateException
-   *              if getReader was already called, or it is a HTTP POST data of type
-   *              application/x-www-form-urlencoded
-   * @exception java.io.IOException
-   *              if an input or output exception occurred
-   */
-  public java.io.InputStream getPortletInputStream() throws java.io.IOException
-  {
-    // mRequest is a protected member of PortletRequestDecorator
-    return ((ActionRequest) mRequest).getPortletInputStream();
-  }
-
-  /**
-   * Overrides the name of the character encoding used in the body of this request. This method must
-   * be called prior to reading input using {@link #getReader} or {@link #getPortletInputStream}.
-   * <p>
-   * This method only sets the character set for the Reader that the {@link #getReader} method
-   * returns.
-   * 
-   * @param enc
-   *          a <code>String</code> containing the name of the chararacter encoding.
-   * 
-   * @exception java.io.UnsupportedEncodingException
-   *              if this is not a valid encoding
-   * @exception java.lang.IllegalStateException
-   *              if this method is called after reading request parameters or reading input using
-   *              <code>getReader()</code>
-   */
-  public void setCharacterEncoding(String enc) throws java.io.UnsupportedEncodingException
-  {
-    // mRequest is a protected member of PortletRequestDecorator
-    ((ActionRequest) mRequest).setCharacterEncoding(enc);
-  }
-
-  /**
-   * Retrieves the body of the HTTP request from the client to the portal as character data using a
-   * <code>BufferedReader</code>. The reader translates the character data according to the
-   * character encoding used on the body. Either this method or {@link #getPortletInputStream} may
-   * be called to read the body, not both.
-   * <p>
-   * For HTTP POST data of type application/x-www-form-urlencoded this method throws an
-   * <code>IllegalStateException</code> as this data has been already processed by the
-   * portal/portlet-container and is available as request parameters.
-   * 
-   * @return a <code>BufferedReader</code> containing the body of the request
-   * 
-   * @exception java.io.UnsupportedEncodingException
-   *              if the character set encoding used is not supported and the text cannot be decoded
-   * @exception java.lang.IllegalStateException
-   *              if {@link #getPortletInputStream} method has been called on this request, it is a
-   *              HTTP POST data of type application/x-www-form-urlencoded.
-   * @exception java.io.IOException
-   *              if an input or output exception occurred
-   * 
-   * @see #getPortletInputStream
-   */
-  public java.io.BufferedReader getReader() throws java.io.UnsupportedEncodingException,
-                                           java.io.IOException
-  {
-    // mRequest is a protected member of PortletRequestDecorator
-    return ((ActionRequest) mRequest).getReader();
-  }
-
-  /**
-   * Returns the name of the character encoding used in the body of this request. This method
-   * returns <code>null</code> if the request does not specify a character encoding.
-   * 
-   * @return a <code>String</code> containing the name of the chararacter encoding, or
-   *         <code>null</code> if the request does not specify a character encoding.
-   */
-  public java.lang.String getCharacterEncoding()
-  {
-    // mRequest is a protected member of PortletRequestDecorator
-    return ((ActionRequest) mRequest).getCharacterEncoding();
-  }
-
-  /**
-   * Returns the MIME type of the body of the request, or null if the type is not known.
-   * 
-   * @return a <code>String</code> containing the name of the MIME type of the request, or null if
-   *         the type is not known.
-   */
-  public java.lang.String getContentType()
-  {
-    // mRequest is a protected member of PortletRequestDecorator
-    return ((ActionRequest) mRequest).getContentType();
-  }
-
-  /**
-   * Returns the length, in bytes, of the request body which is made available by the input stream,
-   * or -1 if the length is not known.
-   * 
-   * 
-   * @return an integer containing the length of the request body or -1 if the length is not known
-   * 
-   */
-  public int getContentLength()
-  {
-    // mRequest is a protected member of PortletRequestDecorator
-    return ((ActionRequest) mRequest).getContentLength();
-  }
-
-}
+/* 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.portlet.faces.bridge.wrapper;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.PortletRequest;
+
+public class ActionRequestDecorator extends PortletRequestDecorator implements ActionRequest
+{
+  private PortletRequest mRequest = null;
+
+  public ActionRequestDecorator(ActionRequest request) throws IllegalArgumentException
+  {
+
+    super(request);
+  }
+
+  /**
+   * Retrieves the body of the HTTP request from client to portal as binary data using an
+   * <CODE>InputStream</CODE>. Either this method or {@link #getReader} may be called to read the
+   * body, but not both.
+   * <p>
+   * For HTTP POST data of type application/x-www-form-urlencoded this method throws an
+   * <code>IllegalStateException</code> as this data has been already processed by the
+   * portal/portlet-container and is available as request parameters.
+   * 
+   * @return an input stream containing the body of the request
+   * 
+   * @exception java.lang.IllegalStateException
+   *              if getReader was already called, or it is a HTTP POST data of type
+   *              application/x-www-form-urlencoded
+   * @exception java.io.IOException
+   *              if an input or output exception occurred
+   */
+  public java.io.InputStream getPortletInputStream() throws java.io.IOException
+  {
+    // mRequest is a protected member of PortletRequestDecorator
+    return ((ActionRequest) mRequest).getPortletInputStream();
+  }
+
+  /**
+   * Overrides the name of the character encoding used in the body of this request. This method must
+   * be called prior to reading input using {@link #getReader} or {@link #getPortletInputStream}.
+   * <p>
+   * This method only sets the character set for the Reader that the {@link #getReader} method
+   * returns.
+   * 
+   * @param enc
+   *          a <code>String</code> containing the name of the chararacter encoding.
+   * 
+   * @exception java.io.UnsupportedEncodingException
+   *              if this is not a valid encoding
+   * @exception java.lang.IllegalStateException
+   *              if this method is called after reading request parameters or reading input using
+   *              <code>getReader()</code>
+   */
+  public void setCharacterEncoding(String enc) throws java.io.UnsupportedEncodingException
+  {
+    // mRequest is a protected member of PortletRequestDecorator
+    ((ActionRequest) mRequest).setCharacterEncoding(enc);
+  }
+
+  /**
+   * Retrieves the body of the HTTP request from the client to the portal as character data using a
+   * <code>BufferedReader</code>. The reader translates the character data according to the
+   * character encoding used on the body. Either this method or {@link #getPortletInputStream} may
+   * be called to read the body, not both.
+   * <p>
+   * For HTTP POST data of type application/x-www-form-urlencoded this method throws an
+   * <code>IllegalStateException</code> as this data has been already processed by the
+   * portal/portlet-container and is available as request parameters.
+   * 
+   * @return a <code>BufferedReader</code> containing the body of the request
+   * 
+   * @exception java.io.UnsupportedEncodingException
+   *              if the character set encoding used is not supported and the text cannot be decoded
+   * @exception java.lang.IllegalStateException
+   *              if {@link #getPortletInputStream} method has been called on this request, it is a
+   *              HTTP POST data of type application/x-www-form-urlencoded.
+   * @exception java.io.IOException
+   *              if an input or output exception occurred
+   * 
+   * @see #getPortletInputStream
+   */
+  public java.io.BufferedReader getReader() throws java.io.UnsupportedEncodingException,
+                                           java.io.IOException
+  {
+    // mRequest is a protected member of PortletRequestDecorator
+    return ((ActionRequest) mRequest).getReader();
+  }
+
+  /**
+   * Returns the name of the character encoding used in the body of this request. This method
+   * returns <code>null</code> if the request does not specify a character encoding.
+   * 
+   * @return a <code>String</code> containing the name of the chararacter encoding, or
+   *         <code>null</code> if the request does not specify a character encoding.
+   */
+  public java.lang.String getCharacterEncoding()
+  {
+    // mRequest is a protected member of PortletRequestDecorator
+    return ((ActionRequest) mRequest).getCharacterEncoding();
+  }
+
+  /**
+   * Returns the MIME type of the body of the request, or null if the type is not known.
+   * 
+   * @return a <code>String</code> containing the name of the MIME type of the request, or null if
+   *         the type is not known.
+   */
+  public java.lang.String getContentType()
+  {
+    // mRequest is a protected member of PortletRequestDecorator
+    return ((ActionRequest) mRequest).getContentType();
+  }
+
+  /**
+   * Returns the length, in bytes, of the request body which is made available by the input stream,
+   * or -1 if the length is not known.
+   * 
+   * 
+   * @return an integer containing the length of the request body or -1 if the length is not known
+   * 
+   */
+  public int getContentLength()
+  {
+    // mRequest is a protected member of PortletRequestDecorator
+    return ((ActionRequest) mRequest).getContentLength();
+  }
+
+}

Modified: myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionResponseDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionResponseDecorator.java?rev=596365&r1=596364&r2=596365&view=diff
==============================================================================
--- myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionResponseDecorator.java (original)
+++ myfaces/portlet-bridge/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/wrapper/ActionResponseDecorator.java Mon Nov 19 08:56:29 2007
@@ -1,225 +1,225 @@
-/* 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.portlet.faces.bridge.wrapper;
-
-import javax.portlet.ActionResponse;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletModeException;
-import javax.portlet.WindowState;
-import javax.portlet.WindowStateException;
-
-public class ActionResponseDecorator extends PortletResponseDecorator implements ActionResponse
-{
-
-  public ActionResponseDecorator(ActionResponse response) throws IllegalArgumentException
-  {
-
-    super(response);
-  }
-
-  @Override
-  public ActionResponse getParent()
-  {
-    return (ActionResponse) super.getParent();
-  }
-
-  @Override
-  public ActionResponse getRoot()
-  {
-    return (ActionResponse) super.getRoot();
-  }
-
-  /**
-   * Sets the window state of a portlet to the given window state.
-   * <p>
-   * Possible values are the standard window states and any custom window states supported by the
-   * portal and the portlet. Standard window states are:
-   * <ul>
-   * <li>MINIMIZED
-   * <li>NORMAL
-   * <li>MAXIMIZED
-   * </ul>
-   * 
-   * @param windowState
-   *          the new portlet window state
-   * 
-   * @exception WindowStateException
-   *              if the portlet cannot switch to the specified window state. To avoid this
-   *              exception the portlet can check the allowed window states with
-   *              <code>Request.isWindowStateAllowed()</code>.
-   * @exception java.lang.IllegalStateException
-   *              if the method is invoked after <code>sendRedirect</code> has been called.
-   * 
-   * @see WindowState
-   */
-  public void setWindowState(WindowState windowState) throws WindowStateException
-  {
-    // mResponse is a protected memeber of PortletResponseDecorator
-    ((ActionResponse) mResponse).setWindowState(windowState);
-  }
-
-  /**
-   * Sets the portlet mode of a portlet to the given portlet mode.
-   * <p>
-   * Possible values are the standard portlet modes and any custom portlet modes supported by the
-   * portal and the portlet. Portlets must declare in the deployment descriptor the portlet modes
-   * they support for each markup type. Standard portlet modes are:
-   * <ul>
-   * <li>EDIT
-   * <li>HELP
-   * <li>VIEW
-   * </ul>
-   * <p>
-   * Note: The portlet may still be called in a different window state in the next render call,
-   * depending on the portlet container / portal.
-   * 
-   * @param portletMode
-   *          the new portlet mode
-   * 
-   * @exception PortletModeException
-   *              if the portlet cannot switch to this portlet mode, because the portlet or portal
-   *              does not support it for this markup, or the current user is not allowed to switch
-   *              to this portlet mode. To avoid this exception the portlet can check the allowed
-   *              portlet modes with <code>Request.isPortletModeAllowed()</code>.
-   * @exception java.lang.IllegalStateException
-   *              if the method is invoked after <code>sendRedirect</code> has been called.
-   */
-  public void setPortletMode(PortletMode portletMode) throws PortletModeException
-  {
-    // mResponse is a protected memeber of PortletResponseDecorator
-    ((ActionResponse) mResponse).setPortletMode(portletMode);
-  }
-
-  /**
-   * Instructs the portlet container to send a redirect response to the client using the specified
-   * redirect location URL.
-   * <p>
-   * This method only accepts an absolute URL (e.g.
-   * <code>http://my.co/myportal/mywebap/myfolder/myresource.gif</code>) or a full path URI (e.g.
-   * <code>/myportal/mywebap/myfolder/myresource.gif</code>). If required, the portlet container
-   * may encode the given URL before the redirection is issued to the client.
-   * <p>
-   * The sendRedirect method can not be invoked after any of the following methods of the
-   * ActionResponse interface has been called:
-   * <ul>
-   * <li>setPortletMode
-   * <li>setWindowState
-   * <li>setRenderParameter
-   * <li>setRenderParameters
-   * </ul>
-   * 
-   * @param location
-   *          the redirect location URL
-   * 
-   * @exception java.io.IOException
-   *              if an input or output exception occurs.
-   * @exception java.lang.IllegalArgumentException
-   *              if a relative path URL is given
-   * @exception java.lang.IllegalStateException
-   *              if the method is invoked after any of above mentioned methods of the
-   *              ActionResponse interface has been called.
-   */
-  public void sendRedirect(String location) throws java.io.IOException
-  {
-    // mResponse is a protected memeber of PortletResponseDecorator
-    ((ActionResponse) mResponse).sendRedirect(location);
-  }
-
-  /**
-   * Sets a parameter map for the render request.
-   * <p>
-   * All previously set render parameters are cleared.
-   * <p>
-   * These parameters will be accessible in all sub-sequent render calls via the
-   * <code>PortletRequest.getParameter</code> call until a new request is targeted to the portlet.
-   * <p>
-   * The given parameters do not need to be encoded prior to calling this method.
-   * 
-   * @param parameters
-   *          Map containing parameter names for the render phase as keys and parameter values as
-   *          map values. The keys in the parameter map must be of type String. The values in the
-   *          parameter map must be of type String array (<code>String[]</code>).
-   * 
-   * @exception java.lang.IllegalArgumentException
-   *              if parameters is <code>null</code>, if any of the key/values in the Map are
-   *              <code>null</code>, if any of the keys is not a String, or if any of the values
-   *              is not a String array.
-   * @exception java.lang.IllegalStateException
-   *              if the method is invoked after <code>sendRedirect</code> has been called.
-   */
-  public void setRenderParameters(java.util.Map parameters)
-  {
-    // mResponse is a protected memeber of PortletResponseDecorator
-    ((ActionResponse) mResponse).setRenderParameters(parameters);
-  }
-
-  /**
-   * Sets a String parameter for the render request.
-   * <p>
-   * These parameters will be accessible in all sub-sequent render calls via the
-   * <code>PortletRequest.getParameter</code> call until a request is targeted to the portlet.
-   * <p>
-   * This method replaces all parameters with the given key.
-   * <p>
-   * The given parameter do not need to be encoded prior to calling this method.
-   * 
-   * @param key
-   *          key of the render parameter
-   * @param value
-   *          value of the render parameter
-   * 
-   * @exception java.lang.IllegalArgumentException
-   *              if key or value are <code>null</code>.
-   * @exception java.lang.IllegalStateException
-   *              if the method is invoked after <code>sendRedirect</code> has been called.
-   */
-  public void setRenderParameter(String key, String value)
-  {
-    // mResponse is a protected memeber of PortletResponseDecorator
-    ((ActionResponse) mResponse).setRenderParameter(key, value);
-  }
-
-  /**
-   * Sets a String array parameter for the render request.
-   * <p>
-   * These parameters will be accessible in all sub-sequent render calls via the
-   * <code>PortletRequest.getParameter</code> call until a request is targeted to the portlet.
-   * <p>
-   * This method replaces all parameters with the given key.
-   * <p>
-   * The given parameter do not need to be encoded prior to calling this method.
-   * 
-   * @param key
-   *          key of the render parameter
-   * @param values
-   *          values of the render parameter
-   * 
-   * @exception java.lang.IllegalArgumentException
-   *              if key or value are <code>null</code>.
-   * @exception java.lang.IllegalStateException
-   *              if the method is invoked after <code>sendRedirect</code> has been called.
-   */
-  public void setRenderParameter(String key, String[] values)
-  {
-    // mResponse is a protected memeber of PortletResponseDecorator
-    ((ActionResponse) mResponse).setRenderParameter(key, values);
-  }
-
-}
+/* 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.portlet.faces.bridge.wrapper;
+
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletModeException;
+import javax.portlet.WindowState;
+import javax.portlet.WindowStateException;
+
+public class ActionResponseDecorator extends PortletResponseDecorator implements ActionResponse
+{
+
+  public ActionResponseDecorator(ActionResponse response) throws IllegalArgumentException
+  {
+
+    super(response);
+  }
+
+  @Override
+  public ActionResponse getParent()
+  {
+    return (ActionResponse) super.getParent();
+  }
+
+  @Override
+  public ActionResponse getRoot()
+  {
+    return (ActionResponse) super.getRoot();
+  }
+
+  /**
+   * Sets the window state of a portlet to the given window state.
+   * <p>
+   * Possible values are the standard window states and any custom window states supported by the
+   * portal and the portlet. Standard window states are:
+   * <ul>
+   * <li>MINIMIZED
+   * <li>NORMAL
+   * <li>MAXIMIZED
+   * </ul>
+   * 
+   * @param windowState
+   *          the new portlet window state
+   * 
+   * @exception WindowStateException
+   *              if the portlet cannot switch to the specified window state. To avoid this
+   *              exception the portlet can check the allowed window states with
+   *              <code>Request.isWindowStateAllowed()</code>.
+   * @exception java.lang.IllegalStateException
+   *              if the method is invoked after <code>sendRedirect</code> has been called.
+   * 
+   * @see WindowState
+   */
+  public void setWindowState(WindowState windowState) throws WindowStateException
+  {
+    // mResponse is a protected memeber of PortletResponseDecorator
+    ((ActionResponse) mResponse).setWindowState(windowState);
+  }
+
+  /**
+   * Sets the portlet mode of a portlet to the given portlet mode.
+   * <p>
+   * Possible values are the standard portlet modes and any custom portlet modes supported by the
+   * portal and the portlet. Portlets must declare in the deployment descriptor the portlet modes
+   * they support for each markup type. Standard portlet modes are:
+   * <ul>
+   * <li>EDIT
+   * <li>HELP
+   * <li>VIEW
+   * </ul>
+   * <p>
+   * Note: The portlet may still be called in a different window state in the next render call,
+   * depending on the portlet container / portal.
+   * 
+   * @param portletMode
+   *          the new portlet mode
+   * 
+   * @exception PortletModeException
+   *              if the portlet cannot switch to this portlet mode, because the portlet or portal
+   *              does not support it for this markup, or the current user is not allowed to switch
+   *              to this portlet mode. To avoid this exception the portlet can check the allowed
+   *              portlet modes with <code>Request.isPortletModeAllowed()</code>.
+   * @exception java.lang.IllegalStateException
+   *              if the method is invoked after <code>sendRedirect</code> has been called.
+   */
+  public void setPortletMode(PortletMode portletMode) throws PortletModeException
+  {
+    // mResponse is a protected memeber of PortletResponseDecorator
+    ((ActionResponse) mResponse).setPortletMode(portletMode);
+  }
+
+  /**
+   * Instructs the portlet container to send a redirect response to the client using the specified
+   * redirect location URL.
+   * <p>
+   * This method only accepts an absolute URL (e.g.
+   * <code>http://my.co/myportal/mywebap/myfolder/myresource.gif</code>) or a full path URI (e.g.
+   * <code>/myportal/mywebap/myfolder/myresource.gif</code>). If required, the portlet container
+   * may encode the given URL before the redirection is issued to the client.
+   * <p>
+   * The sendRedirect method can not be invoked after any of the following methods of the
+   * ActionResponse interface has been called:
+   * <ul>
+   * <li>setPortletMode
+   * <li>setWindowState
+   * <li>setRenderParameter
+   * <li>setRenderParameters
+   * </ul>
+   * 
+   * @param location
+   *          the redirect location URL
+   * 
+   * @exception java.io.IOException
+   *              if an input or output exception occurs.
+   * @exception java.lang.IllegalArgumentException
+   *              if a relative path URL is given
+   * @exception java.lang.IllegalStateException
+   *              if the method is invoked after any of above mentioned methods of the
+   *              ActionResponse interface has been called.
+   */
+  public void sendRedirect(String location) throws java.io.IOException
+  {
+    // mResponse is a protected memeber of PortletResponseDecorator
+    ((ActionResponse) mResponse).sendRedirect(location);
+  }
+
+  /**
+   * Sets a parameter map for the render request.
+   * <p>
+   * All previously set render parameters are cleared.
+   * <p>
+   * These parameters will be accessible in all sub-sequent render calls via the
+   * <code>PortletRequest.getParameter</code> call until a new request is targeted to the portlet.
+   * <p>
+   * The given parameters do not need to be encoded prior to calling this method.
+   * 
+   * @param parameters
+   *          Map containing parameter names for the render phase as keys and parameter values as
+   *          map values. The keys in the parameter map must be of type String. The values in the
+   *          parameter map must be of type String array (<code>String[]</code>).
+   * 
+   * @exception java.lang.IllegalArgumentException
+   *              if parameters is <code>null</code>, if any of the key/values in the Map are
+   *              <code>null</code>, if any of the keys is not a String, or if any of the values
+   *              is not a String array.
+   * @exception java.lang.IllegalStateException
+   *              if the method is invoked after <code>sendRedirect</code> has been called.
+   */
+  public void setRenderParameters(java.util.Map parameters)
+  {
+    // mResponse is a protected memeber of PortletResponseDecorator
+    ((ActionResponse) mResponse).setRenderParameters(parameters);
+  }
+
+  /**
+   * Sets a String parameter for the render request.
+   * <p>
+   * These parameters will be accessible in all sub-sequent render calls via the
+   * <code>PortletRequest.getParameter</code> call until a request is targeted to the portlet.
+   * <p>
+   * This method replaces all parameters with the given key.
+   * <p>
+   * The given parameter do not need to be encoded prior to calling this method.
+   * 
+   * @param key
+   *          key of the render parameter
+   * @param value
+   *          value of the render parameter
+   * 
+   * @exception java.lang.IllegalArgumentException
+   *              if key or value are <code>null</code>.
+   * @exception java.lang.IllegalStateException
+   *              if the method is invoked after <code>sendRedirect</code> has been called.
+   */
+  public void setRenderParameter(String key, String value)
+  {
+    // mResponse is a protected memeber of PortletResponseDecorator
+    ((ActionResponse) mResponse).setRenderParameter(key, value);
+  }
+
+  /**
+   * Sets a String array parameter for the render request.
+   * <p>
+   * These parameters will be accessible in all sub-sequent render calls via the
+   * <code>PortletRequest.getParameter</code> call until a request is targeted to the portlet.
+   * <p>
+   * This method replaces all parameters with the given key.
+   * <p>
+   * The given parameter do not need to be encoded prior to calling this method.
+   * 
+   * @param key
+   *          key of the render parameter
+   * @param values
+   *          values of the render parameter
+   * 
+   * @exception java.lang.IllegalArgumentException
+   *              if key or value are <code>null</code>.
+   * @exception java.lang.IllegalStateException
+   *              if the method is invoked after <code>sendRedirect</code> has been called.
+   */
+  public void setRenderParameter(String key, String[] values)
+  {
+    // mResponse is a protected memeber of PortletResponseDecorator
+    ((ActionResponse) mResponse).setRenderParameter(key, values);
+  }
+
+}