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  public class PortletActionProviderImpl implements PortletActionProvider {
31  
32  
33      private HttpServletRequest request;
34      private PortletWindow portletWindow;
35  
36      public PortletActionProviderImpl(HttpServletRequest request,
37                                       ServletConfig config,
38                                       PortletWindow portletWindow)
39      {
40          this.request = request;
41          this.portletWindow = portletWindow;
42      }
43  
44      // PortletActionProvider implementation.
45  
46      /* (non-Javadoc)
47       * @see org.apache.pluto.services.information.PortletActionProvider#changePortletMode(PortletWindow, PortletMode)
48       */
49      public void changePortletMode(PortletMode mode) 
50      {
51          PortalEnvironment env = PortalEnvironment.getPortalEnvironment(request);
52  
53          PortalURL url = env.getRequestedPortalURL();
54          PortalControlParameter controlURL = new PortalControlParameter(url);
55          if (!(controlURL.getMode(portletWindow).equals(mode)) && mode != null) {
56              controlURL.setMode(portletWindow, mode);
57              env.changeRequestedPortalURL(url, controlURL);
58          }
59      }
60  
61      /* (non-Javadoc)
62       * @see org.apache.pluto.services.information.PortletActionProvider#changePortletWindowState(PortletWindow, WindowState)
63       */
64      public void changePortletWindowState(WindowState state) 
65      {
66          PortalEnvironment env = (PortalEnvironment) request.getAttribute(PortalEnvironment.REQUEST_PORTALENV);
67  
68          PortalURL url = env.getRequestedPortalURL();
69          PortalControlParameter controlURL = new PortalControlParameter(url);
70  
71          if (!(controlURL.getState(portletWindow).equals(state)) && state != null) {
72              controlURL.setState(portletWindow, state);
73              env.changeRequestedPortalURL(url, controlURL);
74          }
75      }
76  
77  }