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