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 at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.modules.actions.controls;
1819// Turbine stuff20import org.apache.turbine.modules.Action;
21import org.apache.turbine.util.RunData;
2223// Jetspeed stuff24import org.apache.jetspeed.portal.Portlet;
25import org.apache.jetspeed.portal.PortletState;
26import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
27import org.apache.jetspeed.services.logging.JetspeedLogger;
28import org.apache.jetspeed.services.PortletFactory;
29import org.apache.jetspeed.services.rundata.JetspeedRunData;
30import org.apache.jetspeed.om.profile.Entry;
3132/***33* Change the internal state of a portlet from normal to minimized34*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*/38publicclassMinimizeextends Action
39 {
4041/***42 * Static initialization of the logger for this class43 */44privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(Minimize.class.getName());
4546/***47 * @param rundata The RunData object for the current request48 */49publicvoid doPerform( RunData rundata ) throws Exception
50 {
51// Only logged in users can minmize52if( rundata.getUser() == null)
53 {
54return;
55 }
5657// Get jsp_peid parmameter. If it does not exist, then do nothing58 String peid = rundata.getParameters().getString("js_peid");
59if ( peid == null )
60 {
61return;
62 }
6364JetspeedRunData jdata = (JetspeedRunData)rundata;
6566// Get the Portlet using the PSML document and the PEID67Entry entry = jdata.getProfile().getDocument().getEntryById(peid);
68if ( entry == null )
69 {
70if (logger.isWarnEnabled())
71 {
72 logger.warn("Failed to get PEID (" + peid + ") entry for User ("73 + rundata.getUser().getName() + ")");
74 }
75return;
76 }
77Portlet portlet = PortletFactory.getPortlet(entry);
7879// Now set the portlet to minimized80if (( portlet != null )&&( portlet instanceof PortletState ))
81 {
82if (logger.isDebugEnabled())
83 {
84 logger.debug("peid = " + peid);
85 logger.debug("portlet id = " + portlet.getID());
86 }
87if (portlet.getID().equals(peid))
88 {
89 ((PortletState)portlet).setMinimized( true, rundata );
90 }
91 }
92 }
93 }