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.portlet.PortletMode;
23  import javax.portlet.WindowState;
24  import javax.servlet.ServletConfig;
25  import javax.servlet.http.HttpServletRequest;
26  
27  import org.apache.pluto.om.window.PortletWindow;
28  import org.apache.pluto.services.information.PortletActionProvider;
29  
30  /***
31  
32   *
33   * To change this generated comment edit the template variable "typecomment":
34   * Window>Preferences>Java>Templates.
35   * To enable and disable the creation of type comments go to
36   * Window>Preferences>Java>Code Generation.
37   */
38  public class PortletActionProviderImpl implements PortletActionProvider {
39  
40  
41      private HttpServletRequest request;
42      private ServletConfig config;
43      private PortletWindow portletWindow;
44  
45      public PortletActionProviderImpl(HttpServletRequest request,
46                                       ServletConfig config,
47                                       PortletWindow portletWindow)
48      {
49          this.request = request;
50          this.config = config;
51          this.portletWindow = portletWindow;
52      }
53  
54      // PortletActionProvider implementation.
55  
56      /* (non-Javadoc)
57       * @see org.apache.pluto.services.information.PortletActionProvider#changePortletMode(PortletWindow, PortletMode)
58       */
59      public void changePortletMode(PortletMode mode) 
60      {
61          PortalEnvironment env = PortalEnvironment.getPortalEnvironment(request);
62  
63          PortalURL url = env.getRequestedPortalURL();
64          PortalControlParameter controlURL = new PortalControlParameter(url);
65          if (!(controlURL.getMode(portletWindow).equals(mode)) && mode != null) {
66              controlURL.setMode(portletWindow, mode);
67              env.changeRequestedPortalURL(url, controlURL);
68          }
69      }
70  
71      /* (non-Javadoc)
72       * @see org.apache.pluto.services.information.PortletActionProvider#changePortletWindowState(PortletWindow, WindowState)
73       */
74      public void changePortletWindowState(WindowState state) 
75      {
76          PortalEnvironment env = (PortalEnvironment) request.getAttribute(PortalEnvironment.REQUEST_PORTALENV);
77  
78          PortalURL url = env.getRequestedPortalURL();
79          PortalControlParameter controlURL = new PortalControlParameter(url);
80  
81          if (!(controlURL.getState(portletWindow).equals(state)) && state != null) {
82              controlURL.setState(portletWindow, state);
83              env.changeRequestedPortalURL(url, controlURL);
84          }
85      }
86  
87  }