View Javadoc

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