KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > modules > actions > controls > Minimize


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.portal.Portlet;
25 import org.apache.jetspeed.portal.PortletState;
26 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
27 import org.apache.jetspeed.services.logging.JetspeedLogger;
28 import org.apache.jetspeed.services.PortletFactory;
29 import org.apache.jetspeed.services.rundata.JetspeedRunData;
30 import org.apache.jetspeed.om.profile.Entry;
31
32 /**
33 * Change the internal state of a portlet from normal to minimized
34 *
35 * @author <a HREF="mailto:re_carrasco@bco011.sonda.cl">Roberto Carrasco</a>
36 * @author <a HREF="mailto:paulsp@apache.org">Paul Spencer</a>
37 */

38 public class Minimize extends Action
39 {
40     
41     /**
42      * Static initialization of the logger for this class
43      */

44     private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(Minimize.class.getName());
45     
46     /**
47      * @param rundata The RunData object for the current request
48      */

49     public void doPerform( RunData rundata ) throws Exception JavaDoc
50     {
51         // Only logged in users can minmize
52
if( rundata.getUser() == null)
53         {
54             return;
55         }
56
57         // Get jsp_peid parmameter. If it does not exist, then do nothing
58
String JavaDoc peid = rundata.getParameters().getString("js_peid");
59         if ( peid == null )
60         {
61             return;
62         }
63         
64         JetspeedRunData jdata = (JetspeedRunData)rundata;
65
66         // Get the Portlet using the PSML document and the PEID
67
Entry entry = jdata.getProfile().getDocument().getEntryById(peid);
68         if ( entry == null )
69         {
70             if (logger.isWarnEnabled())
71             {
72                 logger.warn("Failed to get PEID (" + peid + ") entry for User ("
73                   + rundata.getUser().getName() + ")");
74             }
75             return;
76         }
77         Portlet portlet = PortletFactory.getPortlet(entry);
78         
79         // Now set the portlet to minimized
80
if (( portlet != null )&&( portlet instanceof PortletState ))
81         {
82             if (logger.isDebugEnabled())
83             {
84                 logger.debug("peid = " + peid);
85                 logger.debug("portlet id = " + portlet.getID());
86             }
87             if (portlet.getID().equals(peid))
88             {
89                 ((PortletState)portlet).setMinimized( true, rundata );
90             }
91         }
92     }
93 }
94
Popular Tags