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<String>();
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 return DoPrivilegedUtil.wrap(new PortletPreferencesPrivilegedAction());
346 }
347
348 public PortletPreferencesImpl getPreferencesImpl() {
349 return (PortletPreferencesImpl)_preferences;
350 }
351
352 @Override
353 public Map<String, String[]> getPrivateParameterMap() {
354 Map<String, String[]> parameterMap = null;
355
356 if (_portletRequestDispatcherRequest != null) {
357 parameterMap = _portletRequestDispatcherRequest.getParameterMap();
358 }
359 else {
360 parameterMap = _request.getParameterMap();
361 }
362
363 Map<String, String[]> privateParameterMap = null;
364
365 for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
366 String name = entry.getKey();
367
368 if (_portlet.getPublicRenderParameter(name) != null) {
369 continue;
370 }
371
372 if (privateParameterMap == null) {
373 privateParameterMap = new HashMap<String, String[]>(
374 parameterMap.size(), 1);
375 }
376
377 privateParameterMap.put(name, entry.getValue());
378 }
379
380 if (privateParameterMap == null) {
381 return Collections.emptyMap();
382 }
383
384 return Collections.unmodifiableMap(privateParameterMap);
385 }
386
387 @Override
388 public Enumeration<String> getProperties(String name) {
389 List<String> values = new ArrayList<String>();
390
391 String value = _portalContext.getProperty(name);
392
393 if (value != null) {
394 values.add(value);
395 }
396
397 return Collections.enumeration(values);
398 }
399
400 @Override
401 public String getProperty(String name) {
402 return _portalContext.getProperty(name);
403 }
404
405 @Override
406 public Enumeration<String> getPropertyNames() {
407 return _portalContext.getPropertyNames();
408 }
409
410 @Override
411 public Map<String, String[]> getPublicParameterMap() {
412 Map<String, String[]> parameterMap = null;
413
414 if (_portletRequestDispatcherRequest != null) {
415 parameterMap = _portletRequestDispatcherRequest.getParameterMap();
416 }
417 else {
418 parameterMap = _request.getParameterMap();
419 }
420
421 Map<String, String[]> publicParameterMap = null;
422
423 for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
424 String name = entry.getKey();
425
426 if (_portlet.getPublicRenderParameter(name) != null) {
427 if (publicParameterMap == null) {
428 publicParameterMap = new HashMap<String, String[]>(
429 parameterMap.size(), 1);
430 }
431
432 publicParameterMap.put(name, entry.getValue());
433 }
434 }
435
436 if (publicParameterMap == null) {
437 return Collections.emptyMap();
438 }
439 else {
440 return Collections.unmodifiableMap(publicParameterMap);
441 }
442 }
443
444 @Override
445 public String getRemoteUser() {
446 return _remoteUser;
447 }
448
449 @Override
450 public Map<String, String[]> getRenderParameters() {
451 return RenderParametersPool.get(_request, _plid, _portletName);
452 }
453
454 @Override
455 public String getRequestedSessionId() {
456 if (_session != null) {
457 return _session.getId();
458 }
459
460 HttpSession session = _request.getSession(false);
461
462 if (session == null) {
463 return StringPool.BLANK;
464 }
465 else {
466 return session.getId();
467 }
468 }
469
470 @Override
471 public String getResponseContentType() {
472 if (_wapTheme) {
473 return ContentTypes.XHTML_MP;
474 }
475 else {
476 return ContentTypes.TEXT_HTML;
477 }
478 }
479
480 @Override
481 public Enumeration<String> getResponseContentTypes() {
482 List<String> responseContentTypes = new ArrayList<String>();
483
484 responseContentTypes.add(getResponseContentType());
485
486 return Collections.enumeration(responseContentTypes);
487 }
488
489 @Override
490 public String getScheme() {
491 return _request.getScheme();
492 }
493
494 @Override
495 public String getServerName() {
496 return _request.getServerName();
497 }
498
499 @Override
500 public int getServerPort() {
501 return _request.getServerPort();
502 }
503
504 public LinkedHashMap<String, String> getUserInfo() {
505 return UserInfoFactory.getUserInfo(_remoteUserId, _portlet);
506 }
507
508 @Override
509 public Principal getUserPrincipal() {
510 return _userPrincipal;
511 }
512
513 @Override
514 public String getWindowID() {
515 return _portletName.concat(
516 LiferayPortletSession.LAYOUT_SEPARATOR).concat(
517 String.valueOf(_plid));
518 }
519
520 @Override
521 public WindowState getWindowState() {
522 return _windowState;
523 }
524
525 public void invalidateSession() {
526 _invalidSession = true;
527 }
528
529 public boolean isInvalidParameter(String name) {
530 if (Validator.isNull(name) ||
531 name.startsWith(PortletQName.PUBLIC_RENDER_PARAMETER_NAMESPACE) ||
532 name.startsWith(
533 PortletQName.REMOVE_PUBLIC_RENDER_PARAMETER_NAMESPACE) ||
534 PortalUtil.isReservedParameter(name)) {
535
536 return true;
537 }
538
539 if (_strutsPortlet) {
540 Matcher matcher = _strutsPortletIgnoredParamtersPattern.matcher(
541 name);
542
543 if (matcher.matches()) {
544 return true;
545 }
546 }
547
548 return false;
549 }
550
551 @Override
552 public boolean isPortletModeAllowed(PortletMode portletMode) {
553 if ((portletMode == null) || Validator.isNull(portletMode.toString())) {
554 return true;
555 }
556 else {
557 return _portlet.hasPortletMode(
558 getResponseContentType(), portletMode);
559 }
560 }
561
562 public boolean isPrivateRequestAttributes() {
563 return _portlet.isPrivateRequestAttributes();
564 }
565
566 @Override
567 public boolean isRequestedSessionIdValid() {
568 return _request.isRequestedSessionIdValid();
569 }
570
571 @Override
572 public boolean isSecure() {
573 return _request.isSecure();
574 }
575
576 public boolean isTriggeredByActionURL() {
577 return _triggeredByActionURL;
578 }
579
580 @Override
581 public boolean isUserInRole(String role) {
582 if (_remoteUserId <= 0) {
583 return false;
584 }
585
586 try {
587 long companyId = PortalUtil.getCompanyId(_request);
588
589 String roleLink = _portlet.getRoleMappers().get(role);
590
591 if (Validator.isNotNull(roleLink)) {
592 return RoleLocalServiceUtil.hasUserRole(
593 _remoteUserId, companyId, roleLink, true);
594 }
595 else {
596 return RoleLocalServiceUtil.hasUserRole(
597 _remoteUserId, companyId, role, true);
598 }
599 }
600 catch (Exception e) {
601 _log.error(e);
602 }
603
604 return _request.isUserInRole(role);
605 }
606
607 @Override
608 public boolean isWindowStateAllowed(WindowState windowState) {
609 return PortalContextImpl.isSupportedWindowState(windowState);
610 }
611
612 @Override
613 public void removeAttribute(String name) {
614 if (name == null) {
615 throw new IllegalArgumentException();
616 }
617
618 _request.removeAttribute(name);
619 }
620
621 @Override
622 public void setAttribute(String name, Object obj) {
623 if (name == null) {
624 throw new IllegalArgumentException();
625 }
626
627 if (obj == null) {
628 removeAttribute(name);
629 }
630 else {
631 _request.setAttribute(name, obj);
632 }
633 }
634
635 public void setPortletMode(PortletMode portletMode) {
636 _portletMode = portletMode;
637 }
638
639 public void setPortletRequestDispatcherRequest(HttpServletRequest request) {
640 _portletRequestDispatcherRequest = request;
641 }
642
643 public void setWindowState(WindowState windowState) {
644 _windowState = windowState;
645 }
646
647 protected void init(
648 HttpServletRequest request, Portlet portlet,
649 InvokerPortlet invokerPortlet, PortletContext portletContext,
650 WindowState windowState, PortletMode portletMode,
651 PortletPreferences preferences, long plid) {
652
653 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
654 WebKeys.THEME_DISPLAY);
655
656 _portlet = portlet;
657 _portletName = portlet.getPortletId();
658 _publicRenderParameters = PublicRenderParametersPool.get(request, plid);
659
660 if (invokerPortlet != null) {
661 if (invokerPortlet.isStrutsPortlet() ||
662 invokerPortlet.isStrutsBridgePortlet()) {
663
664 _strutsPortlet = true;
665 }
666 }
667
668 String portletNamespace = PortalUtil.getPortletNamespace(_portletName);
669
670 PortletApp portletApp = portlet.getPortletApp();
671
672 boolean warFile = portletApp.isWARFile();
673
674 if (!warFile) {
675 String portletResource = ParamUtil.getString(
676 request, portletNamespace.concat("portletResource"));
677
678 if (Validator.isNotNull(portletResource)) {
679 Portlet resourcePortlet = null;
680
681 try {
682 resourcePortlet = PortletLocalServiceUtil.getPortletById(
683 themeDisplay.getCompanyId(), portletResource);
684 }
685 catch (Exception e) {
686 }
687
688 if (resourcePortlet != null) {
689 PortletApp resourcePortletApp =
690 resourcePortlet.getPortletApp();
691
692 if (resourcePortletApp.isWARFile()) {
693 warFile = true;
694 }
695 }
696 }
697 }
698
699 if (warFile) {
700 request = new SharedSessionServletRequest(
701 request, !portlet.isPrivateSessionAttributes());
702 }
703
704 String dynamicQueryString = (String)request.getAttribute(
705 DynamicServletRequest.DYNAMIC_QUERY_STRING);
706
707 if (dynamicQueryString != null) {
708 request.removeAttribute(DynamicServletRequest.DYNAMIC_QUERY_STRING);
709
710 request = DynamicServletRequest.addQueryString(
711 request, dynamicQueryString, true);
712 }
713
714 DynamicServletRequest dynamicRequest = null;
715
716 if (portlet.isPrivateRequestAttributes()) {
717 dynamicRequest = new NamespaceServletRequest(
718 request, portletNamespace, portletNamespace, false);
719 }
720 else {
721 dynamicRequest = new DynamicServletRequest(request, false);
722 }
723
724 boolean portletFocus = false;
725
726 String ppid = ParamUtil.getString(request, "p_p_id");
727
728 boolean windowStateRestoreCurrentView = ParamUtil.getBoolean(
729 request, "p_p_state_rcv");
730
731 if (_portletName.equals(ppid) &&
732 !(windowStateRestoreCurrentView &&
733 portlet.isRestoreCurrentView())) {
734
735
736
737 if (themeDisplay.isLifecycleRender() ||
738 themeDisplay.isLifecycleResource()) {
739
740
741
742 portletFocus = true;
743 }
744 else if (themeDisplay.isLifecycleAction()) {
745 _triggeredByActionURL = true;
746
747 if (getLifecycle().equals(PortletRequest.ACTION_PHASE)) {
748
749
750
751
752 portletFocus = true;
753 }
754 }
755 }
756
757 if (portletFocus) {
758 Map<String, String[]> renderParameters =
759 new HashMap<String, String[]>();
760
761 if (getLifecycle().equals(PortletRequest.RENDER_PHASE) &&
762 !LiferayWindowState.isExclusive(request) &&
763 !LiferayWindowState.isPopUp(request)) {
764
765 RenderParametersPool.put(
766 request, plid, _portletName, renderParameters);
767 }
768
769 Map<String, String[]> parameters = request.getParameterMap();
770
771 for (Map.Entry<String, String[]> entry : parameters.entrySet()) {
772 String name = entry.getKey();
773
774 if (isInvalidParameter(name)) {
775 continue;
776 }
777
778 String[] values = entry.getValue();
779
780 if (themeDisplay.isLifecycleRender()) {
781 renderParameters.put(name, values);
782 }
783
784 if (values == null) {
785 continue;
786 }
787
788 if ((invokerPortlet != null) &&
789 invokerPortlet.isFacesPortlet()) {
790
791 if (name.startsWith(portletNamespace) ||
792 !portlet.isRequiresNamespacedParameters()) {
793
794 dynamicRequest.setParameterValues(name, values);
795 }
796 }
797 else {
798 String realName = removePortletNamespace(
799 portletNamespace, name);
800
801 if (!realName.equals(name) ||
802 !portlet.isRequiresNamespacedParameters()) {
803
804 dynamicRequest.setParameterValues(realName, values);
805 }
806 }
807 }
808 }
809 else {
810 Map<String, String[]> renderParameters = RenderParametersPool.get(
811 request, plid, _portletName);
812
813 for (Map.Entry<String, String[]> entry :
814 renderParameters.entrySet()) {
815
816 String name = entry.getKey();
817 String[] values = entry.getValue();
818
819 if ((invokerPortlet == null) ||
820 !invokerPortlet.isFacesPortlet()) {
821
822 name = removePortletNamespace(portletNamespace, name);
823 }
824
825 dynamicRequest.setParameterValues(name, values);
826 }
827 }
828
829 mergePublicRenderParameters(dynamicRequest, preferences, plid);
830
831 _request = dynamicRequest;
832 _originalRequest = request;
833 _wapTheme = BrowserSnifferUtil.isWap(_request);
834 _portlet = portlet;
835 _portalContext = new PortalContextImpl();
836 _portletContext = portletContext;
837 _windowState = windowState;
838 _portletMode = portletMode;
839 _preferences = preferences;
840 _session = new PortletSessionImpl(
841 _request.getSession(), _portletContext, _portletName, plid);
842
843 String remoteUser = request.getRemoteUser();
844
845 String userPrincipalStrategy = portlet.getUserPrincipalStrategy();
846
847 if (userPrincipalStrategy.equals(
848 PortletConstants.USER_PRINCIPAL_STRATEGY_SCREEN_NAME)) {
849
850 try {
851 User user = PortalUtil.getUser(request);
852
853 if (user != null) {
854 _remoteUser = user.getScreenName();
855 _remoteUserId = user.getUserId();
856 _userPrincipal = new ProtectedPrincipal(_remoteUser);
857 }
858 }
859 catch (Exception e) {
860 _log.error(e);
861 }
862 }
863 else {
864 long userId = PortalUtil.getUserId(request);
865
866 if ((userId > 0) && (remoteUser == null)) {
867 _remoteUser = String.valueOf(userId);
868 _remoteUserId = userId;
869 _userPrincipal = new ProtectedPrincipal(_remoteUser);
870 }
871 else {
872 _remoteUser = remoteUser;
873 _remoteUserId = GetterUtil.getLong(remoteUser);
874 _userPrincipal = request.getUserPrincipal();
875 }
876 }
877
878 _locale = themeDisplay.getLocale();
879 _plid = plid;
880 }
881
882 protected void mergePublicRenderParameters(
883 DynamicServletRequest dynamicRequest, PortletPreferences preferences,
884 long plid) {
885
886 Enumeration<PublicRenderParameter> publicRenderParameters =
887 Collections.enumeration(_portlet.getPublicRenderParameters());
888
889 while (publicRenderParameters.hasMoreElements()) {
890 PublicRenderParameter publicRenderParameter =
891 publicRenderParameters.nextElement();
892
893 String ignoreKey = PublicRenderParameterConfiguration.getIgnoreKey(
894 publicRenderParameter);
895
896 boolean ignoreValue = GetterUtil.getBoolean(
897 preferences.getValue(ignoreKey, null));
898
899 if (ignoreValue) {
900 continue;
901 }
902
903 String mappingKey =
904 PublicRenderParameterConfiguration.getMappingKey(
905 publicRenderParameter);
906
907 String mappingValue = GetterUtil.getString(
908 preferences.getValue(mappingKey, null));
909
910 HttpServletRequest request =
911 (HttpServletRequest)dynamicRequest.getRequest();
912
913 String[] newValues = request.getParameterValues(mappingValue);
914
915 if ((newValues != null) && (newValues.length != 0)) {
916 newValues = ArrayUtil.remove(newValues, StringPool.NULL);
917 }
918
919 String name = publicRenderParameter.getIdentifier();
920
921 if (ArrayUtil.isEmpty(newValues)) {
922 QName qName = publicRenderParameter.getQName();
923
924 String[] values = _publicRenderParameters.get(
925 PortletQNameUtil.getPublicRenderParameterName(qName));
926
927 if (ArrayUtil.isEmpty(values) || Validator.isNull(values[0])) {
928 continue;
929 }
930
931 if (dynamicRequest.getParameter(name) == null) {
932 dynamicRequest.setParameterValues(name, values);
933 }
934 }
935 else {
936 dynamicRequest.setParameterValues(name, newValues);
937 }
938 }
939 }
940
941 protected String removePortletNamespace(
942 String portletNamespace, String name) {
943
944 if (name.startsWith(portletNamespace)) {
945 name = name.substring(portletNamespace.length());
946 }
947
948 return name;
949 }
950
951 private static final Log _log = LogFactoryUtil.getLog(
952 PortletRequestImpl.class);
953
954 private static final Pattern _strutsPortletIgnoredParamtersPattern =
955 Pattern.compile(PropsValues.STRUTS_PORTLET_IGNORED_PARAMETERS_REGEXP);
956
957 private boolean _invalidSession;
958 private Locale _locale;
959 private HttpServletRequest _originalRequest;
960 private long _plid;
961 private PortalContext _portalContext;
962 private Portlet _portlet;
963 private PortletContext _portletContext;
964 private PortletMode _portletMode;
965 private String _portletName;
966 private HttpServletRequest _portletRequestDispatcherRequest;
967 private PortletPreferences _preferences;
968 private Profile _profile;
969 private Map<String, String[]> _publicRenderParameters;
970 private String _remoteUser;
971 private long _remoteUserId;
972 private HttpServletRequest _request;
973 private PortletSessionImpl _session;
974 private boolean _strutsPortlet;
975 private boolean _triggeredByActionURL;
976 private Principal _userPrincipal;
977 private boolean _wapTheme;
978 private WindowState _windowState;
979
980 private class PortletPreferencesPrivilegedAction
981 implements PrivilegedAction<PortletPreferences> {
982
983 @Override
984 public PortletPreferences run() {
985 return new PortletPreferencesWrapper(
986 getPreferencesImpl(), getLifecycle());
987 }
988
989 }
990
991 }