protected void mergePublicRenderParameters( DynamicServletRequest dynamicRequest, PortletPreferences preferences, long plid) { Enumeration<PublicRenderParameter> publicRenderParameters = Collections.enumeration(_portlet.getPublicRenderParameters()); while (publicRenderParameters.hasMoreElements()) { PublicRenderParameter publicRenderParameter = publicRenderParameters.nextElement(); String ignoreKey = PublicRenderParameterConfiguration.getIgnoreKey(publicRenderParameter); boolean ignoreValue = GetterUtil.getBoolean(preferences.getValue(ignoreKey, null)); if (ignoreValue) { continue; } String mappingKey = PublicRenderParameterConfiguration.getMappingKey(publicRenderParameter); String mappingValue = GetterUtil.getString(preferences.getValue(mappingKey, null)); HttpServletRequest request = (HttpServletRequest) dynamicRequest.getRequest(); String[] newValues = request.getParameterValues(mappingValue); if ((newValues != null) && (newValues.length != 0)) { newValues = ArrayUtil.remove(newValues, StringPool.NULL); } String name = publicRenderParameter.getIdentifier(); if ((newValues == null) || (newValues.length == 0)) { QName qName = publicRenderParameter.getQName(); String[] values = _publicRenderParameters.get(PortletQNameUtil.getPublicRenderParameterName(qName)); if ((values) == null || (values.length == 0) || (Validator.isNull(values[0]))) { continue; } if (dynamicRequest.getParameter(name) == null) { dynamicRequest.setParameterValues(name, values); } } else { dynamicRequest.setParameterValues(name, newValues); } } }
public DynamicServletRequest( HttpServletRequest request, Map<String, String[]> params, boolean inherit) { super(request); _params = new HashMap<String, String[]>(); _inherit = inherit; if (params != null) { for (Map.Entry<String, String[]> entry : params.entrySet()) { _params.put(entry.getKey(), entry.getValue()); } } if (_inherit && (request instanceof DynamicServletRequest)) { DynamicServletRequest dynamicRequest = (DynamicServletRequest) request; setRequest(dynamicRequest.getRequest()); params = dynamicRequest.getDynamicParameterMap(); if (params != null) { for (Map.Entry<String, String[]> entry : params.entrySet()) { String name = entry.getKey(); String[] oldValues = entry.getValue(); String[] curValues = _params.get(name); if (curValues == null) { _params.put(name, oldValues); } else { String[] newValues = ArrayUtil.append(oldValues, curValues); _params.put(name, newValues); } } } } }
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; _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; }