View Javadoc

1   /*
2    * Copyright 2003,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  /* 
17  
18   */
19  
20  package org.apache.pluto.portalImpl.core;
21  
22  import javax.servlet.ServletConfig;
23  import javax.servlet.http.HttpServletRequest;
24  import javax.servlet.http.HttpServletResponse;
25  
26  public class PortalEnvironment
27  {
28  
29      public final static String REQUEST_PORTALENV = "org.apache.pluto.portalImpl.core.PortalEnvironment";
30  
31      private HttpServletRequest request;
32      private HttpServletResponse response;
33      private ServletConfig config;
34  
35      private PortalURL              requestedPortalURL;
36      private PortalControlParameter portalControl;
37  
38      public PortalEnvironment(HttpServletRequest request,
39                               HttpServletResponse response, 
40                               ServletConfig config)
41      {
42          this.request = request;
43          this.response = response;
44          this.config = config;
45  
46          requestedPortalURL = new PortalURL(this);
47          // get navigational information and prepare PortalURL object        
48          requestedPortalURL.analyzeRequestInformation();
49          portalControl = new PortalControlParameter(requestedPortalURL);
50  
51          // set Environment in Request for later use
52          this.request.setAttribute(REQUEST_PORTALENV, this);
53      }
54  
55      public static PortalEnvironment getPortalEnvironment(HttpServletRequest request)
56      {
57          return (PortalEnvironment)request.getAttribute(REQUEST_PORTALENV);
58      }
59  
60      public HttpServletRequest getRequest()
61      {
62          return request;
63      }
64  
65      public HttpServletResponse getResponse()
66      {
67          return response;
68      }
69  
70      public ServletConfig getConfig()
71      {
72          return config;
73      }
74  /*
75      public List getNavigationalInformation()
76      {
77          return navigationalInformation;
78      }
79  */    
80      public PortalURL getRequestedPortalURL()
81      {
82          return requestedPortalURL;
83      }
84  
85      public PortalControlParameter getPortalControlParameter() {
86          return portalControl;
87      }
88  
89      public void changeRequestedPortalURL(PortalURL url, PortalControlParameter control)
90      {
91          requestedPortalURL = url;
92          requestedPortalURL.analyzeControlInformation(control);
93          portalControl = control;
94      }
95  
96  }