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