View Javadoc

1   /*
2    * Copyright 2000-2001,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  package org.apache.jetspeed.modules.actions.controls;
18  
19  // Turbine stuff
20  import org.apache.turbine.modules.Action;
21  import org.apache.turbine.util.RunData;
22  
23  // Jetspeed stuff
24  import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
25  import org.apache.jetspeed.services.logging.JetspeedLogger;
26  import org.apache.jetspeed.services.rundata.JetspeedRunData;
27  import org.apache.jetspeed.om.profile.Entry;
28  
29  /***
30   * Change the state of a portlet to maximized. This setting is not persistent.
31   * Since the maximized state affects the whole screen, this action redirects
32   * the user to a new template and store the state to go to when clicking on
33   * restore
34   * 
35   * @author <a href="mailto:re_carrasco@bco011.sonda.cl">Roberto Carrasco</a>
36   * @author <a href="mailto:raphael@apache.org">RaphaŽl Luta</a>
37   * @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
38   */
39  public class Maximize extends Action
40  {
41      
42      /***
43       * Static initialization of the logger for this class
44       */
45      private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(Maximize.class.getName());
46      
47      /***
48       * @param rundata The RunData object for the current request
49       */    
50      public void doPerform( RunData rundata ) throws Exception
51      {
52          // Only logged in users can maximize
53          if( rundata.getUser() == null)
54          {
55              return;
56          }
57          // Get jsp_peid parmameter.  If it does not exist, then do nothing
58          String peid = rundata.getParameters().getString("js_peid");
59          if ( peid == null )
60          {
61              return;
62          }
63          
64          // Get the Portlet using the PSML document and the PEID
65          JetspeedRunData jdata = (JetspeedRunData)rundata;
66  
67          // Get the Portlet using the PSML document and the PEID
68          Entry entry = jdata.getProfile().getDocument().getEntryById(peid);
69          if ( entry == null )
70          {
71              logger.warn("Failed to get PEID (" + peid + ") entry for User (" 
72                + rundata.getUser().getName() + ")");
73              return;
74          }
75  
76          //record that this portlet is now maximized
77          jdata.getUser().setTemp("js_peid",peid);
78  
79      }
80  }