001    /**
002     * Copyright (c) 2000-2013 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.kernel.servlet.DynamicServletRequest;
018    import com.liferay.portal.model.User;
019    import com.liferay.portal.struts.PortletAction;
020    import com.liferay.portal.util.PortalUtil;
021    import com.liferay.portlet.RenderRequestImpl;
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            @Override
039            public ActionForward render(
040                            ActionMapping actionMapping, ActionForm actionForm,
041                            PortletConfig portletConfig, RenderRequest renderRequest,
042                            RenderResponse renderResponse)
043                    throws Exception {
044    
045                    if (renderRequest.getRemoteUser() == null) {
046                            return actionMapping.findForward("portlet.my_account.view");
047                    }
048    
049                    if (!renderRequest.getWindowState().equals(WindowState.MAXIMIZED)) {
050                            return actionMapping.findForward("portlet.my_account.view");
051                    }
052    
053                    User user = PortalUtil.getUser(renderRequest);
054    
055                    RenderRequestImpl renderRequestImpl = (RenderRequestImpl)renderRequest;
056    
057                    DynamicServletRequest dynamicRequest =
058                            (DynamicServletRequest)renderRequestImpl.getHttpServletRequest();
059    
060                    dynamicRequest.setParameter(
061                            "p_u_i_d", String.valueOf(user.getUserId()));
062    
063                    return actionMapping.findForward("portlet.my_account.edit_user");
064            }
065    
066    }