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 javax.servlet.http.HttpServletRequest;
    20  import java.util.Enumeration;
    21
    22  /***
    23   * <p>
    24   * This must be the set of properties available via the javax.portlet.PortletRequest methods getProperty()
    25   * and getPropertyNames(). As such, HTTP headers will only be included if they were provided by the portlet container,
    26   * and additional properties provided by the portlet container may also be included.
    27   * @author Apache MyFaces team
    28   */
    29  public class ServletRequestHeaderMap extends AbstractAttributeMap
    30  {
    31      /*** The portlet request. */
    32      private final HttpServletRequest servletRequest;
    33
    34      /***
    35       * @param portletRequest The {@link javax.portlet.PortletRequest}.
    36       */
    37      ServletRequestHeaderMap(HttpServletRequest portletRequest)
    38      {
    39          this.servletRequest = portletRequest;
    40      }
    41
    42      /***
    43       * @see AbstractAttributeMap#getAttribute(String)
    44       */
    45      protected Object getAttribute(String key)
    46      {
    47          return servletRequest.getHeader(key);
    48      }
    49
    50      /***
    51       * @see AbstractAttributeMap#setAttribute(String, Object)
    52       */
    53      protected void setAttribute(String key, Object value)
    54      {
    55          throw new UnsupportedOperationException(
    56              "Cannot set PortletRequest Property");
    57      }
    58
    59      /***
    60       * @see AbstractAttributeMap#removeAttribute(String)
    61       */
    62      protected void removeAttribute(String key)
    63      {
    64          throw new UnsupportedOperationException(
    65              "Cannot remove PortletRequest Property");
    66      }
    67
    68      /***
    69       * @see AbstractAttributeMap#getAttributeNames()
    70       */
    71      protected Enumeration getAttributeNames()
    72      {
    73          return servletRequest.getHeaderNames();
    74      }
    75  }