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.jetspeed.aggregator.impl;
18  
19  import javax.portlet.PortletPreferences;
20  
21  import org.apache.jetspeed.portlet.PortletHeaderRequest;
22  import org.apache.jetspeed.request.RequestContext;
23  import org.apache.pluto.core.impl.PortletPreferencesImpl;
24  import org.apache.pluto.om.common.ParameterSet;
25  import org.apache.pluto.om.common.Parameter;
26  import org.apache.pluto.om.window.PortletWindow;
27  
28  
29  public class PortletHeaderRequestImpl implements PortletHeaderRequest
30  {
31      private RequestContext requestContext;
32      private String portletApplicationContextPath;
33      private PortletWindow portletWindow;
34      private ParameterSet initParamSet;
35      
36      public PortletHeaderRequestImpl( RequestContext requestContext, PortletWindow portletWindow, String portletApplicationContextPath )
37      {
38          this.requestContext = requestContext;
39          this.portletApplicationContextPath = portletApplicationContextPath;
40          this.portletWindow = portletWindow;
41      }
42      
43      public String getPortalContextPath()
44      {
45          return requestContext.getRequest().getContextPath();
46      }    
47      
48      public PortletPreferences getPreferences()
49      {
50          return new PortletPreferencesImpl(org.apache.pluto.Constants.METHOD_NOOP, this.portletWindow.getPortletEntity());
51      }
52      
53      public String getInitParameter( String name )
54      {
55          ParameterSet iParamSet = this.initParamSet;
56          if ( iParamSet == null )
57          {
58              iParamSet = this.portletWindow.getPortletEntity().getPortletDefinition().getInitParameterSet();
59              this.initParamSet = iParamSet;
60          }
61          if ( iParamSet != null )
62          {
63              Parameter initParam = iParamSet.get( name );
64              if ( initParam != null )
65              {
66                  return initParam.getValue();
67              }
68          }
69          return null;
70      }
71      
72      /***
73       * @return Returns the portletApplicationContextPath.
74       */
75      public String getPortletApplicationContextPath()
76      {
77          return portletApplicationContextPath;
78      }
79      
80  }