001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.myaccount.action;
016    
017    import com.liferay.portal.model.User;
018    import com.liferay.portal.struts.PortletAction;
019    import com.liferay.portal.util.PortalUtil;
020    import com.liferay.portlet.RenderRequestImpl;
021    import com.liferay.util.servlet.DynamicServletRequest;
022    
023    import javax.portlet.PortletConfig;
024    import javax.portlet.RenderRequest;
025    import javax.portlet.RenderResponse;
026    import javax.portlet.WindowState;
027    
028    import org.apache.struts.action.ActionForm;
029    import org.apache.struts.action.ActionForward;
030    import org.apache.struts.action.ActionMapping;
031    
032    /**
033     * @author Brian Wing Shun Chan
034     * @author Jorge Ferrer
035     */
036    public class ViewAction extends PortletAction {
037    
038            public ActionForward render(
039                            ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
040                            RenderRequest renderRequest, RenderResponse renderResponse)
041                    throws Exception {
042    
043                    if (renderRequest.getRemoteUser() == null) {
044                            return mapping.findForward("portlet.my_account.view");
045                    }
046    
047                    if (!renderRequest.getWindowState().equals(WindowState.MAXIMIZED)) {
048                            return mapping.findForward("portlet.my_account.view");
049                    }
050    
051                    User user = PortalUtil.getUser(renderRequest);
052    
053                    RenderRequestImpl renderRequestImpl = (RenderRequestImpl)renderRequest;
054    
055                    DynamicServletRequest dynamicRequest =
056                            (DynamicServletRequest)renderRequestImpl.getHttpServletRequest();
057    
058                    dynamicRequest.setParameter(
059                            "p_u_i_d", String.valueOf(user.getUserId()));
060    
061                    return mapping.findForward("portlet.my_account.edit_user");
062            }
063    
064    }