View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  package org.apache.portals.bridges.jsf;
    18
    19  import java.util.Enumeration;
    20
    21  import javax.portlet.PortletRequest;
    22
    23  /***
    24   * <p>
    25   * This must be the set of properties available via the javax.portlet.PortletRequest methods getProperty()
    26   * and getPropertyNames(). As such, HTTP headers will only be included if they were provided by the portlet container,
    27   * and additional properties provided by the portlet container may also be included.
    28   * </p>
    29   * <p>
    30   * See MyFaces project for servlet implementation.
    31   * </p>
    32   *
    33   * @author <a href="dlestrat@apache.org">David Le Strat </a>
    34   */
    35  public class RequestHeaderMap extends AbstractAttributeMap
    36  {
    37      /*** The portlet request. */
    38      private final PortletRequest portletRequest;
    39
    40      /***
    41       * @param portletRequest The {@link PortletRequest}.
    42       */
    43      RequestHeaderMap(PortletRequest portletRequest)
    44      {
    45          this.portletRequest = portletRequest;
    46      }
    47
    48      /***
    49       * @see org.apache.portals.bridges.jsf.AbstractAttributeMap#getAttribute(java.lang.String)
    50       */
    51      protected Object getAttribute(String key)
    52      {
    53          return portletRequest.getProperty(key);
    54      }
    55
    56      /***
    57       * @see org.apache.portals.bridges.jsf.AbstractAttributeMap#setAttribute(java.lang.String, java.lang.Object)
    58       */
    59      protected void setAttribute(String key, Object value)
    60      {
    61          throw new UnsupportedOperationException(
    62              "Cannot set PortletRequest Property");
    63      }
    64
    65      /***
    66       * @see org.apache.portals.bridges.jsf.AbstractAttributeMap#removeAttribute(java.lang.String)
    67       */
    68      protected void removeAttribute(String key)
    69      {
    70          throw new UnsupportedOperationException(
    71              "Cannot remove PortletRequest Property");
    72      }
    73
    74      /***
    75       * @see org.apache.portals.bridges.jsf.AbstractAttributeMap#getAttributeNames()
    76       */
    77      protected Enumeration getAttributeNames()
    78      {
    79          return portletRequest.getPropertyNames();
    80      }
    81  }