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/***33Change the internal state of a portlet from minimized to normal3435@author <a href="mailto:re_carrasco@bco011.sonda.cl">Roberto Carrasco</a>36@author <a href="mailto:paulsp@apache">Paul Spencer</a>37*/38publicclassRestoreextends Action
39 {
4041/***42 * Static initialization of the logger for this class43 */44privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(Restore.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 Restored52if( 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 }
6364// Get the Portlet using the PSML document and the PEID65JetspeedRunData jdata = (JetspeedRunData)rundata;
66Entry entry = jdata.getProfile().getDocument().getEntryById(peid);
67if ( entry == null )
68 {
69 logger.warn("Failed to get PEID (" + peid + ") entry for User ("70 + rundata.getUser().getName() + ")");
71return;
72 }
73Portlet portlet = PortletFactory.getPortlet(entry);
7475// Now unset the portlet to minimized76if (( portlet != null )&&( portlet instanceof PortletState ))
77 {
78 ((PortletState)portlet).setMinimized( false, rundata );
79 }
8081// make sure we use the default template82while (jdata.getCustomized()!=null)
83 {
84 jdata.setCustomized(null);
85 }
8687//remove the maximized portlet name - nothing is maximized now88 jdata.getUser().removeTemp("js_peid");
8990 jdata.setScreenTemplate("Home");
91 }
9293 }