001    /**
002     * Copyright (c) 2000-2012 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;
016    
017    import com.liferay.portal.ccpp.PortalProfileFactory;
018    import com.liferay.portal.kernel.log.Log;
019    import com.liferay.portal.kernel.log.LogFactoryUtil;
020    import com.liferay.portal.kernel.portlet.LiferayPortletRequest;
021    import com.liferay.portal.kernel.portlet.LiferayPortletSession;
022    import com.liferay.portal.kernel.portlet.LiferayWindowState;
023    import com.liferay.portal.kernel.servlet.BrowserSnifferUtil;
024    import com.liferay.portal.kernel.servlet.DynamicServletRequest;
025    import com.liferay.portal.kernel.servlet.ProtectedPrincipal;
026    import com.liferay.portal.kernel.servlet.ServletContextPool;
027    import com.liferay.portal.kernel.util.ArrayUtil;
028    import com.liferay.portal.kernel.util.ContentTypes;
029    import com.liferay.portal.kernel.util.ContextPathUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.JavaConstants;
032    import com.liferay.portal.kernel.util.LocaleUtil;
033    import com.liferay.portal.kernel.util.ParamUtil;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.Validator;
036    import com.liferay.portal.kernel.xml.QName;
037    import com.liferay.portal.model.Portlet;
038    import com.liferay.portal.model.PortletApp;
039    import com.liferay.portal.model.PortletConstants;
040    import com.liferay.portal.model.PublicRenderParameter;
041    import com.liferay.portal.model.User;
042    import com.liferay.portal.service.RoleLocalServiceUtil;
043    import com.liferay.portal.servlet.NamespaceServletRequest;
044    import com.liferay.portal.servlet.SharedSessionServletRequest;
045    import com.liferay.portal.theme.ThemeDisplay;
046    import com.liferay.portal.util.PortalUtil;
047    import com.liferay.portal.util.WebKeys;
048    import com.liferay.portlet.portletconfiguration.util.PublicRenderParameterConfiguration;
049    
050    import java.security.Principal;
051    
052    import java.util.ArrayList;
053    import java.util.Collections;
054    import java.util.Enumeration;
055    import java.util.HashMap;
056    import java.util.LinkedHashMap;
057    import java.util.List;
058    import java.util.Locale;
059    import java.util.Map;
060    
061    import javax.ccpp.Profile;
062    
063    import javax.portlet.PortalContext;
064    import javax.portlet.PortletConfig;
065    import javax.portlet.PortletContext;
066    import javax.portlet.PortletMode;
067    import javax.portlet.PortletPreferences;
068    import javax.portlet.PortletRequest;
069    import javax.portlet.PortletResponse;
070    import javax.portlet.PortletSession;
071    import javax.portlet.WindowState;
072    import javax.portlet.filter.PortletRequestWrapper;
073    
074    import javax.servlet.ServletContext;
075    import javax.servlet.http.Cookie;
076    import javax.servlet.http.HttpServletRequest;
077    import javax.servlet.http.HttpSession;
078    
079    /**
080     * @author Brian Wing Shun Chan
081     * @author Brian Myunghun Kim
082     * @author Sergey Ponomarev
083     */
084    public abstract class PortletRequestImpl implements LiferayPortletRequest {
085    
086            public static PortletRequestImpl getPortletRequestImpl(
087                    PortletRequest portletRequest) {
088    
089                    while (!(portletRequest instanceof PortletRequestImpl)) {
090                            if (portletRequest instanceof PortletRequestWrapper) {
091                                    PortletRequestWrapper portletRequestWrapper =
092                                            (PortletRequestWrapper)portletRequest;
093    
094                                    portletRequest = portletRequestWrapper.getRequest();
095                            }
096                            else {
097                                    throw new RuntimeException(
098                                            "Unable to unwrap the portlet request from " +
099                                                    portletRequest.getClass());
100                            }
101                    }
102    
103                    return (PortletRequestImpl)portletRequest;
104            }
105    
106            public void cleanUp() {
107                    _request.removeAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
108                    _request.removeAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);
109                    _request.removeAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE);
110                    _request.removeAttribute(PortletRequest.LIFECYCLE_PHASE);
111                    _request.removeAttribute(WebKeys.PORTLET_ID);
112                    _request.removeAttribute(WebKeys.PORTLET_CONTENT);
113            }
114    
115            public void defineObjects(
116                    PortletConfig portletConfig, PortletResponse portletResponse) {
117    
118                    PortletConfigImpl portletConfigImpl = (PortletConfigImpl)portletConfig;
119    
120                    setAttribute(WebKeys.PORTLET_ID, portletConfigImpl.getPortletId());
121                    setAttribute(JavaConstants.JAVAX_PORTLET_CONFIG, portletConfig);
122                    setAttribute(JavaConstants.JAVAX_PORTLET_REQUEST, this);
123                    setAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE, portletResponse);
124                    setAttribute(PortletRequest.LIFECYCLE_PHASE, getLifecycle());
125            }
126    
127            public Object getAttribute(String name) {
128                    if (name == null) {
129                            throw new IllegalArgumentException();
130                    }
131    
132                    if (name.equals(PortletRequest.CCPP_PROFILE)) {
133                            return getCCPPProfile();
134                    }
135                    else if (name.equals(PortletRequest.USER_INFO)) {
136                            Object value = getUserInfo();
137    
138                            if (value != null) {
139                                    return value;
140                            }
141                    }
142    
143                    return _request.getAttribute(name);
144            }
145    
146            public Enumeration<String> getAttributeNames() {
147                    List<String> names = new ArrayList<String>();
148    
149                    Enumeration<String> enu = _request.getAttributeNames();
150    
151                    while (enu.hasMoreElements()) {
152                            String name = enu.nextElement();
153    
154                            if (!name.equals(JavaConstants.JAVAX_SERVLET_INCLUDE_PATH_INFO)) {
155                                    names.add(name);
156                            }
157                    }
158    
159                    return Collections.enumeration(names);
160            }
161    
162            public String getAuthType() {
163                    return _request.getAuthType();
164            }
165    
166            public Profile getCCPPProfile() {
167                    if (_profile == null) {
168                            _profile = PortalProfileFactory.getCCPPProfile(_request);
169                    }
170    
171                    return _profile;
172            }
173    
174            public String getContextPath() {
175                    PortletContextImpl portletContextImpl =
176                            (PortletContextImpl)_portletContext;
177    
178                    ServletContext servletContext = portletContextImpl.getServletContext();
179    
180                    String servletContextName = servletContext.getServletContextName();
181    
182                    if (ServletContextPool.containsKey(servletContextName)) {
183                            servletContext = ServletContextPool.get(servletContextName);
184    
185                            return ContextPathUtil.getContextPath(servletContext);
186                    }
187    
188                    return StringPool.SLASH.concat(_portletContext.getPortletContextName());
189            }
190    
191            public Cookie[] getCookies() {
192                    return _request.getCookies();
193            }
194    
195            public String getETag() {
196                    return null;
197            }
198    
199            public HttpServletRequest getHttpServletRequest() {
200                    return _request;
201            }
202    
203            public abstract String getLifecycle();
204    
205            public Locale getLocale() {
206                    Locale locale = _locale;
207    
208                    if (locale == null) {
209                            locale = _request.getLocale();
210                    }
211    
212                    if (locale == null) {
213                            locale = LocaleUtil.getDefault();
214                    }
215    
216                    return locale;
217            }
218    
219            public Enumeration<Locale> getLocales() {
220                    return _request.getLocales();
221            }
222    
223            public String getMethod() {
224                    return _request.getMethod();
225            }
226    
227            public HttpServletRequest getOriginalHttpServletRequest() {
228                    return _originalRequest;
229            }
230    
231            public String getParameter(String name) {
232                    if (name == null) {
233                            throw new IllegalArgumentException();
234                    }
235    
236                    if (_portletRequestDispatcherRequest != null) {
237                            return _portletRequestDispatcherRequest.getParameter(name);
238                    }
239    
240                    return _request.getParameter(name);
241            }
242    
243            public Map<String, String[]> getParameterMap() {
244                    if (_portletRequestDispatcherRequest != null) {
245                            return Collections.unmodifiableMap(
246                                    _portletRequestDispatcherRequest.getParameterMap());
247                    }
248    
249                    return Collections.unmodifiableMap(_request.getParameterMap());
250            }
251    
252            public Enumeration<String> getParameterNames() {
253                    if (_portletRequestDispatcherRequest != null) {
254                            return _portletRequestDispatcherRequest.getParameterNames();
255                    }
256    
257                    return _request.getParameterNames();
258            }
259    
260            public String[] getParameterValues(String name) {
261                    if (name == null) {
262                            throw new IllegalArgumentException();
263                    }
264    
265                    if (_portletRequestDispatcherRequest != null) {
266                            return _portletRequestDispatcherRequest.getParameterValues(name);
267                    }
268    
269                    return _request.getParameterValues(name);
270            }
271    
272            public PortalContext getPortalContext() {
273                    return _portalContext;
274            }
275    
276            public Portlet getPortlet() {
277                    return _portlet;
278            }
279    
280            public PortletContext getPortletContext() {
281                    return _portletContext;
282            }
283    
284            public PortletMode getPortletMode() {
285                    return _portletMode;
286            }
287    
288            public String getPortletName() {
289                    return _portletName;
290            }
291    
292            public PortletSession getPortletSession() {
293                    return _session;
294            }
295    
296            public PortletSession getPortletSession(boolean create) {
297                    /*HttpSession httpSes = _req.getSession(create);
298    
299                    if (httpSes == null) {
300                            return null;
301                    }
302                    else {
303                            if (create) {
304                                    _session = new PortletSessionImpl(
305                                            _req.getSession(), _portletContext, _portletName, _plid);
306                            }
307    
308                            return _ses;
309                    }*/
310    
311                    /*if ((_session == null) && create) {
312                            _req.getSession(create);
313    
314                            _session = new PortletSessionImpl(
315                                    _req.getSession(), _portletContext, _portletName, _plid);
316                    }*/
317    
318                    if (!create && _invalidSession) {
319                            return null;
320                    }
321    
322                    return _session;
323            }
324    
325            public PortletPreferences getPreferences() {
326                    return new PortletPreferencesWrapper(
327                            getPreferencesImpl(), getLifecycle());
328            }
329    
330            public PortletPreferencesImpl getPreferencesImpl() {
331                    return (PortletPreferencesImpl)_preferences;
332            }
333    
334            public Map<String, String[]> getPrivateParameterMap() {
335                    Map<String, String[]> parameterMap = null;
336    
337                    if (_portletRequestDispatcherRequest != null) {
338                            parameterMap = _portletRequestDispatcherRequest.getParameterMap();
339                    }
340                    else {
341                            parameterMap = _request.getParameterMap();
342                    }
343    
344                    Map<String, String[]> privateParameterMap = null;
345    
346                    for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
347                            String name = entry.getKey();
348    
349                            if (_portlet.getPublicRenderParameter(name) != null) {
350                                    continue;
351                            }
352    
353                            if (privateParameterMap == null) {
354                                    privateParameterMap = new HashMap<String, String[]>(
355                                            parameterMap.size(), 1);
356                            }
357    
358                            privateParameterMap.put(name, entry.getValue());
359                    }
360    
361                    if (privateParameterMap == null) {
362                            return Collections.emptyMap();
363                    }
364    
365                    return Collections.unmodifiableMap(privateParameterMap);
366            }
367    
368            public Enumeration<String> getProperties(String name) {
369                    List<String> values = new ArrayList<String>();
370    
371                    String value = _portalContext.getProperty(name);
372    
373                    if (value != null) {
374                            values.add(value);
375                    }
376    
377                    return Collections.enumeration(values);
378            }
379    
380            public String getProperty(String name) {
381                    return _portalContext.getProperty(name);
382            }
383    
384            public Enumeration<String> getPropertyNames() {
385                    return _portalContext.getPropertyNames();
386            }
387    
388            public Map<String, String[]> getPublicParameterMap() {
389                    Map<String, String[]> parameterMap = null;
390    
391                    if (_portletRequestDispatcherRequest != null) {
392                            parameterMap = _portletRequestDispatcherRequest.getParameterMap();
393                    }
394                    else {
395                            parameterMap = _request.getParameterMap();
396                    }
397    
398                    Map<String, String[]> publicParameterMap = null;
399    
400                    for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
401                            String name = entry.getKey();
402    
403                            if (_portlet.getPublicRenderParameter(name) != null) {
404    
405                                    if (publicParameterMap == null) {
406                                            publicParameterMap = new HashMap<String, String[]>(
407                                                    parameterMap.size(), 1);
408                                    }
409    
410                                    publicParameterMap.put(name, entry.getValue());
411                            }
412                    }
413    
414                    if (publicParameterMap == null) {
415                            return Collections.emptyMap();
416                    }
417                    else {
418                            return Collections.unmodifiableMap(publicParameterMap);
419                    }
420            }
421    
422            public String getRemoteUser() {
423                    return _remoteUser;
424            }
425    
426            public Map<String, String[]> getRenderParameters() {
427                    return RenderParametersPool.get(_request, _plid, _portletName);
428            }
429    
430            public String getRequestedSessionId() {
431                    if (_session != null) {
432                            return _session.getId();
433                    }
434                    else {
435                            HttpSession session = _request.getSession(false);
436    
437                            if (session == null) {
438                                    return StringPool.BLANK;
439                            }
440                            else {
441                                    return session.getId();
442                            }
443                    }
444            }
445    
446            public String getResponseContentType() {
447                    if (_wapTheme) {
448                            return ContentTypes.XHTML_MP;
449                    }
450                    else {
451                            return ContentTypes.TEXT_HTML;
452                    }
453            }
454    
455            public Enumeration<String> getResponseContentTypes() {
456                    List<String> responseContentTypes = new ArrayList<String>();
457    
458                    responseContentTypes.add(getResponseContentType());
459    
460                    return Collections.enumeration(responseContentTypes);
461            }
462    
463            public String getScheme() {
464                    return _request.getScheme();
465            }
466    
467            public String getServerName() {
468                    return _request.getServerName();
469            }
470    
471            public int getServerPort() {
472                    return _request.getServerPort();
473            }
474    
475            public LinkedHashMap<String, String> getUserInfo() {
476                    return UserInfoFactory.getUserInfo(_remoteUserId, _portlet);
477            }
478    
479            public Principal getUserPrincipal() {
480                    return _userPrincipal;
481            }
482    
483            public String getWindowID() {
484                    return _portletName.concat(
485                            LiferayPortletSession.LAYOUT_SEPARATOR).concat(
486                                    String.valueOf(_plid));
487            }
488    
489            public WindowState getWindowState() {
490                    return _windowState;
491            }
492    
493            public void invalidateSession() {
494                    _invalidSession = true;
495            }
496    
497            public boolean isInvalidParameter(String name) {
498                    if (Validator.isNull(name) ||
499                            name.startsWith(PortletQName.PUBLIC_RENDER_PARAMETER_NAMESPACE) ||
500                            name.startsWith(
501                                    PortletQName.REMOVE_PUBLIC_RENDER_PARAMETER_NAMESPACE) ||
502                            PortalUtil.isReservedParameter(name)) {
503    
504                            return true;
505                    }
506                    else {
507                            return false;
508                    }
509            }
510    
511            public boolean isPortletModeAllowed(PortletMode portletMode) {
512                    if ((portletMode == null) || Validator.isNull(portletMode.toString())) {
513                            return true;
514                    }
515                    else {
516                            return _portlet.hasPortletMode(
517                                    getResponseContentType(), portletMode);
518                    }
519            }
520    
521            public boolean isPrivateRequestAttributes() {
522                    return _portlet.isPrivateRequestAttributes();
523            }
524    
525            public boolean isRequestedSessionIdValid() {
526                    return _request.isRequestedSessionIdValid();
527            }
528    
529            public boolean isSecure() {
530                    return _request.isSecure();
531            }
532    
533            public boolean isTriggeredByActionURL() {
534                    return _triggeredByActionURL;
535            }
536    
537            public boolean isUserInRole(String role) {
538                    if (_remoteUserId <= 0) {
539                            return false;
540                    }
541                    else {
542                            try {
543                                    long companyId = PortalUtil.getCompanyId(_request);
544    
545                                    String roleLink = _portlet.getRoleMappers().get(role);
546    
547                                    if (Validator.isNotNull(roleLink)) {
548                                            return RoleLocalServiceUtil.hasUserRole(
549                                                    _remoteUserId, companyId, roleLink, true);
550                                    }
551                                    else {
552                                            return RoleLocalServiceUtil.hasUserRole(
553                                                    _remoteUserId, companyId, role, true);
554                                    }
555                            }
556                            catch (Exception e) {
557                                    _log.error(e);
558                            }
559    
560                            return _request.isUserInRole(role);
561                    }
562            }
563    
564            public boolean isWindowStateAllowed(WindowState windowState) {
565                    return PortalContextImpl.isSupportedWindowState(windowState);
566            }
567    
568            public void removeAttribute(String name) {
569                    if (name == null) {
570                            throw new IllegalArgumentException();
571                    }
572    
573                    _request.removeAttribute(name);
574            }
575    
576            public void setAttribute(String name, Object obj) {
577                    if (name == null) {
578                            throw new IllegalArgumentException();
579                    }
580    
581                    if (obj == null) {
582                            removeAttribute(name);
583                    }
584                    else {
585                            _request.setAttribute(name, obj);
586                    }
587            }
588    
589            public void setPortletMode(PortletMode portletMode) {
590                    _portletMode = portletMode;
591            }
592    
593            public void setPortletRequestDispatcherRequest(HttpServletRequest request) {
594                    _portletRequestDispatcherRequest = request;
595            }
596    
597            public void setWindowState(WindowState windowState) {
598                    _windowState = windowState;
599            }
600    
601            protected void init(
602                    HttpServletRequest request, Portlet portlet,
603                    InvokerPortlet invokerPortlet, PortletContext portletContext,
604                    WindowState windowState, PortletMode portletMode,
605                    PortletPreferences preferences, long plid) {
606    
607                    ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
608                            WebKeys.THEME_DISPLAY);
609    
610                    _portlet = portlet;
611                    _portletName = portlet.getPortletId();
612                    _publicRenderParameters = PublicRenderParametersPool.get(request, plid);
613    
614                    String portletNamespace = PortalUtil.getPortletNamespace(_portletName);
615    
616                    boolean portalSessionShared = false;
617    
618                    PortletApp portletApp = portlet.getPortletApp();
619    
620                    if (portletApp.isWARFile() && !portlet.isPrivateSessionAttributes()) {
621                            portalSessionShared = true;
622                    }
623    
624                    request = new SharedSessionServletRequest(request, portalSessionShared);
625    
626                    DynamicServletRequest dynamicRequest = null;
627    
628                    if (portlet.isPrivateRequestAttributes()) {
629                            dynamicRequest = new NamespaceServletRequest(
630                                    request, portletNamespace, portletNamespace, false);
631                    }
632                    else {
633                            dynamicRequest = new DynamicServletRequest(request, false);
634                    }
635    
636                    boolean portletFocus = false;
637    
638                    String ppid = ParamUtil.getString(request, "p_p_id");
639    
640                    boolean windowStateRestoreCurrentView = ParamUtil.getBoolean(
641                            request, "p_p_state_rcv");
642    
643                    if (_portletName.equals(ppid) &&
644                            !(windowStateRestoreCurrentView &&
645                              portlet.isRestoreCurrentView())) {
646    
647                            // Request was targeted to this portlet
648    
649                            if (themeDisplay.isLifecycleRender() ||
650                                    themeDisplay.isLifecycleResource()) {
651    
652                                    // Request was triggered by a render or resource URL
653    
654                                    portletFocus = true;
655                            }
656                            else if (themeDisplay.isLifecycleAction()) {
657                                    _triggeredByActionURL = true;
658    
659                                    if (getLifecycle().equals(PortletRequest.ACTION_PHASE)) {
660    
661                                            // Request was triggered by an action URL and is being
662                                            // processed by com.liferay.portlet.ActionRequestImpl
663    
664                                            portletFocus = true;
665                                    }
666                            }
667                    }
668    
669                    if (portletFocus) {
670                            Map<String, String[]> renderParameters =
671                                    new HashMap<String, String[]>();
672    
673                            if (getLifecycle().equals(PortletRequest.RENDER_PHASE) &&
674                                    !LiferayWindowState.isExclusive(request) &&
675                                    !LiferayWindowState.isPopUp(request)) {
676    
677                                    RenderParametersPool.put(
678                                            request, plid, _portletName, renderParameters);
679                            }
680    
681                            Map<String, String[]> parameters = request.getParameterMap();
682    
683                            for (Map.Entry<String, String[]> entry : parameters.entrySet()) {
684                                    String name = entry.getKey();
685    
686                                    if (isInvalidParameter(name)) {
687                                            continue;
688                                    }
689    
690                                    String[] values = entry.getValue();
691    
692                                    if (themeDisplay.isLifecycleRender()) {
693                                            renderParameters.put(name, values);
694                                    }
695    
696                                    if (values == null) {
697                                            continue;
698                                    }
699    
700                                    name = removePortletNamespace(
701                                            invokerPortlet, portletNamespace, name);
702    
703                                    dynamicRequest.setParameterValues(name, values);
704                            }
705                    }
706                    else {
707                            Map<String, String[]> renderParameters = RenderParametersPool.get(
708                                    request, plid, _portletName);
709    
710                            for (Map.Entry<String, String[]> entry :
711                                            renderParameters.entrySet()) {
712    
713                                    String name = entry.getKey();
714                                    String[] values = entry.getValue();
715    
716                                    name = removePortletNamespace(
717                                            invokerPortlet, portletNamespace, name);
718    
719                                    dynamicRequest.setParameterValues(name, values);
720                            }
721                    }
722    
723                    mergePublicRenderParameters(dynamicRequest, preferences, plid);
724    
725                    _request = dynamicRequest;
726                    _originalRequest = request;
727                    _wapTheme = BrowserSnifferUtil.isWap(_request);
728                    _portlet = portlet;
729                    _portalContext = new PortalContextImpl();
730                    _portletContext = portletContext;
731                    _windowState = windowState;
732                    _portletMode = portletMode;
733                    _preferences = preferences;
734                    _session = new PortletSessionImpl(
735                            _request.getSession(), _portletContext, _portletName, plid);
736    
737                    String remoteUser = request.getRemoteUser();
738    
739                    String userPrincipalStrategy = portlet.getUserPrincipalStrategy();
740    
741                    if (userPrincipalStrategy.equals(
742                                    PortletConstants.USER_PRINCIPAL_STRATEGY_SCREEN_NAME)) {
743    
744                            try {
745                                    User user = PortalUtil.getUser(request);
746    
747                                    if (user != null) {
748                                            _remoteUser = user.getScreenName();
749                                            _remoteUserId = user.getUserId();
750                                            _userPrincipal = new ProtectedPrincipal(_remoteUser);
751                                    }
752                            }
753                            catch (Exception e) {
754                                    _log.error(e);
755                            }
756                    }
757                    else {
758                            long userId = PortalUtil.getUserId(request);
759    
760                            if ((userId > 0) && (remoteUser == null)) {
761                                    _remoteUser = String.valueOf(userId);
762                                    _remoteUserId = userId;
763                                    _userPrincipal = new ProtectedPrincipal(_remoteUser);
764                            }
765                            else {
766                                    _remoteUser = remoteUser;
767                                    _remoteUserId = GetterUtil.getLong(remoteUser);
768                                    _userPrincipal = request.getUserPrincipal();
769                            }
770                    }
771    
772                    _locale = themeDisplay.getLocale();
773                    _plid = plid;
774            }
775    
776            protected void mergePublicRenderParameters(
777                    DynamicServletRequest dynamicRequest, PortletPreferences preferences,
778                    long plid) {
779    
780                    Enumeration<PublicRenderParameter> publicRenderParameters =
781                            Collections.enumeration(_portlet.getPublicRenderParameters());
782    
783                    while (publicRenderParameters.hasMoreElements()) {
784                            PublicRenderParameter publicRenderParameter =
785                                    publicRenderParameters.nextElement();
786    
787                            String ignoreKey = PublicRenderParameterConfiguration.getIgnoreKey(
788                                    publicRenderParameter);
789    
790                            boolean ignoreValue = GetterUtil.getBoolean(
791                                    preferences.getValue(ignoreKey, null));
792    
793                            if (ignoreValue) {
794                                    continue;
795                            }
796    
797                            String mappingKey =
798                                    PublicRenderParameterConfiguration.getMappingKey(
799                                            publicRenderParameter);
800    
801                            String mappingValue = GetterUtil.getString(
802                                    preferences.getValue(mappingKey, null));
803    
804                            HttpServletRequest request =
805                                    (HttpServletRequest)dynamicRequest.getRequest();
806    
807                            String[] newValues = request.getParameterValues(mappingValue);
808    
809                            if ((newValues != null) && (newValues.length != 0)) {
810                                    newValues = ArrayUtil.remove(newValues, StringPool.NULL);
811                            }
812    
813                            String name = publicRenderParameter.getIdentifier();
814    
815                            if ((newValues == null) || (newValues.length == 0)) {
816                                    QName qName = publicRenderParameter.getQName();
817    
818                                    String[] values = _publicRenderParameters.get(
819                                            PortletQNameUtil.getPublicRenderParameterName(qName));
820    
821                                    if ((values == null) || (values.length == 0) ||
822                                            Validator.isNull(values[0])) {
823    
824                                            continue;
825                                    }
826    
827                                    if (dynamicRequest.getParameter(name) == null) {
828                                            dynamicRequest.setParameterValues(name, values);
829                                    }
830                            }
831                            else {
832                                    dynamicRequest.setParameterValues(name, newValues);
833                            }
834                    }
835            }
836    
837            protected String removePortletNamespace(
838                    InvokerPortlet invokerPortlet, String portletNamespace, String name) {
839    
840                    if (name.startsWith(portletNamespace) &&
841                            ((invokerPortlet == null) || !invokerPortlet.isFacesPortlet())) {
842    
843                            name = name.substring(portletNamespace.length());
844                    }
845    
846                    return name;
847            }
848    
849            private static Log _log = LogFactoryUtil.getLog(PortletRequestImpl.class);
850    
851            private boolean _invalidSession;
852            private Locale _locale;
853            private HttpServletRequest _originalRequest;
854            private long _plid;
855            private PortalContext _portalContext;
856            private Portlet _portlet;
857            private PortletContext _portletContext;
858            private PortletMode _portletMode;
859            private String _portletName;
860            private HttpServletRequest _portletRequestDispatcherRequest;
861            private PortletPreferences _preferences;
862            private Profile _profile;
863            private Map<String, String[]> _publicRenderParameters;
864            private String _remoteUser;
865            private long _remoteUserId;
866            private HttpServletRequest _request;
867            private PortletSessionImpl _session;
868            private boolean _triggeredByActionURL;
869            private Principal _userPrincipal;
870            private boolean _wapTheme;
871            private WindowState _windowState;
872    
873    }