Example usage for com.liferay.portal.kernel.portlet LiferayWindowState isPopUp

List of usage examples for com.liferay.portal.kernel.portlet LiferayWindowState isPopUp

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.portlet LiferayWindowState isPopUp.

Prototype

public static boolean isPopUp(HttpServletRequest httpServletRequest) 

Source Link

Usage

From source file:com.liferay.portlet.PortletRequestImpl.java

License:Open Source License

protected void init(HttpServletRequest request, Portlet portlet, InvokerPortlet invokerPortlet,
        PortletContext portletContext, WindowState windowState, PortletMode portletMode,
        PortletPreferences preferences, long plid) {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    _portlet = portlet;/*from   w ww.ja  va2 s.c  o  m*/
    _portletName = portlet.getPortletId();
    _publicRenderParameters = PublicRenderParametersPool.get(request, plid);

    String portletNamespace = PortalUtil.getPortletNamespace(_portletName);

    boolean portalSessionShared = false;

    PortletApp portletApp = portlet.getPortletApp();

    if (portletApp.isWARFile() && !portlet.isPrivateSessionAttributes()) {
        portalSessionShared = true;
    }

    request = new SharedSessionServletRequest(request, portalSessionShared);

    DynamicServletRequest dynamicRequest = null;

    if (portlet.isPrivateRequestAttributes()) {
        dynamicRequest = new NamespaceServletRequest(request, portletNamespace, portletNamespace, false);
    } else {
        dynamicRequest = new DynamicServletRequest(request, false);
    }

    boolean portletFocus = false;

    String ppid = ParamUtil.getString(request, "p_p_id");

    boolean windowStateRestoreCurrentView = ParamUtil.getBoolean(request, "p_p_state_rcv");

    if (_portletName.equals(ppid) && !(windowStateRestoreCurrentView && portlet.isRestoreCurrentView())) {

        // Request was targeted to this portlet

        if (themeDisplay.isLifecycleRender() || themeDisplay.isLifecycleResource()) {

            // Request was triggered by a render or resource URL

            portletFocus = true;
        } else if (themeDisplay.isLifecycleAction()) {
            _triggeredByActionURL = true;

            if (getLifecycle().equals(PortletRequest.ACTION_PHASE)) {

                // Request was triggered by an action URL and is being
                // processed by com.liferay.portlet.ActionRequestImpl

                portletFocus = true;
            }
        }
    }

    Map<String, String[]> renderParameters = RenderParametersPool.get(request, plid, _portletName);

    if (portletFocus) {
        renderParameters = new HashMap<String, String[]>();

        if (getLifecycle().equals(PortletRequest.RENDER_PHASE) && !LiferayWindowState.isExclusive(request)
                && !LiferayWindowState.isPopUp(request)) {

            RenderParametersPool.put(request, plid, _portletName, renderParameters);
        }

        Map<String, String[]> parameters = request.getParameterMap();

        for (Map.Entry<String, String[]> entry : parameters.entrySet()) {
            String name = entry.getKey();

            if (isInvalidParameter(name)) {
                continue;
            }

            String[] values = entry.getValue();

            if (themeDisplay.isLifecycleRender()) {
                renderParameters.put(name, values);
            }

            if (values == null) {
                continue;
            }

            name = removePortletNamespace(invokerPortlet, portletNamespace, name);

            dynamicRequest.setParameterValues(name, values);
        }
    } else {
        for (Map.Entry<String, String[]> entry : renderParameters.entrySet()) {

            String name = entry.getKey();
            String[] values = entry.getValue();

            name = removePortletNamespace(invokerPortlet, portletNamespace, name);

            dynamicRequest.setParameterValues(name, values);
        }
    }

    mergePublicRenderParameters(dynamicRequest, preferences, plid);

    _request = dynamicRequest;
    _originalRequest = request;
    _wapTheme = BrowserSnifferUtil.isWap(_request);
    _portlet = portlet;
    _portalContext = new PortalContextImpl();
    _portletContext = portletContext;
    _windowState = windowState;
    _portletMode = portletMode;
    _preferences = preferences;
    _portalSessionId = _request.getRequestedSessionId();
    _session = new PortletSessionImpl(_request, _portletName, _portletContext, _portalSessionId, plid);

    String remoteUser = request.getRemoteUser();

    String userPrincipalStrategy = portlet.getUserPrincipalStrategy();

    if (userPrincipalStrategy.equals(PortletConstants.USER_PRINCIPAL_STRATEGY_SCREEN_NAME)) {

        try {
            User user = PortalUtil.getUser(request);

            if (user != null) {
                _remoteUser = user.getScreenName();
                _remoteUserId = user.getUserId();
                _userPrincipal = new ProtectedPrincipal(_remoteUser);
            }
        } catch (Exception e) {
            _log.error(e);
        }
    } else {
        long userId = PortalUtil.getUserId(request);

        if ((userId > 0) && (remoteUser == null)) {
            _remoteUser = String.valueOf(userId);
            _remoteUserId = userId;
            _userPrincipal = new ProtectedPrincipal(_remoteUser);
        } else {
            _remoteUser = remoteUser;
            _remoteUserId = GetterUtil.getLong(remoteUser);
            _userPrincipal = request.getUserPrincipal();
        }
    }

    _locale = themeDisplay.getLocale();
    _plid = plid;
}