001    /**
002     * Copyright (c) 2000-present 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.login.action;
016    
017    import com.liferay.portal.kernel.portlet.bridges.mvc.MVCRenderCommand;
018    import com.liferay.portal.kernel.spring.osgi.OSGiBeanProperties;
019    import com.liferay.portal.kernel.util.JavaConstants;
020    import com.liferay.portal.model.Company;
021    import com.liferay.portal.theme.ThemeDisplay;
022    import com.liferay.portal.util.PortletKeys;
023    import com.liferay.portal.util.WebKeys;
024    
025    import javax.portlet.PortletConfig;
026    import javax.portlet.RenderRequest;
027    import javax.portlet.RenderResponse;
028    
029    /**
030     * @author Peter Fellwock
031     */
032    @OSGiBeanProperties(
033            property = {
034                    "javax.portlet.name=" + PortletKeys.FAST_LOGIN,
035                    "javax.portlet.name=" + PortletKeys.LOGIN,
036                    "mvc.command.name=/login/create_anonymous_account"
037            }
038    )
039    public class CreateAnonymousAccountMVCRenderCommand
040            implements MVCRenderCommand {
041    
042            @Override
043            public String render(
044                    RenderRequest renderRequest, RenderResponse renderResponse) {
045    
046                    ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(
047                            WebKeys.THEME_DISPLAY);
048    
049                    Company company = themeDisplay.getCompany();
050    
051                    if (!company.isStrangers()) {
052                            return "/html/portlet/login/login.jsp";
053                    }
054    
055                    PortletConfig portletConfig = (PortletConfig)renderRequest.getAttribute(
056                            JavaConstants.JAVAX_PORTLET_CONFIG);
057    
058                    String portletName = portletConfig.getPortletName();
059    
060                    if (!portletName.equals(PortletKeys.FAST_LOGIN)) {
061                            return "/html/portlet/login/login.jsp";
062                    }
063    
064                    renderResponse.setTitle(themeDisplay.translate("anonymous-account"));
065    
066                    return "/html/portlet/login/create_anonymous_account.jsp";
067            }
068    
069    }