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.LiferayPortletContext;
022 import com.liferay.portal.kernel.portlet.LiferayPortletRequest;
023 import com.liferay.portal.kernel.portlet.LiferayPortletSession;
024 import com.liferay.portal.kernel.portlet.LiferayWindowState;
025 import com.liferay.portal.kernel.servlet.BrowserSnifferUtil;
026 import com.liferay.portal.kernel.servlet.DynamicServletRequest;
027 import com.liferay.portal.kernel.servlet.ProtectedPrincipal;
028 import com.liferay.portal.kernel.servlet.ServletContextPool;
029 import com.liferay.portal.kernel.util.ArrayUtil;
030 import com.liferay.portal.kernel.util.ContentTypes;
031 import com.liferay.portal.kernel.util.ContextPathUtil;
032 import com.liferay.portal.kernel.util.GetterUtil;
033 import com.liferay.portal.kernel.util.JavaConstants;
034 import com.liferay.portal.kernel.util.LocaleUtil;
035 import com.liferay.portal.kernel.util.ParamUtil;
036 import com.liferay.portal.kernel.util.StringPool;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.kernel.xml.QName;
039 import com.liferay.portal.model.Portlet;
040 import com.liferay.portal.model.PortletApp;
041 import com.liferay.portal.model.PortletConstants;
042 import com.liferay.portal.model.PublicRenderParameter;
043 import com.liferay.portal.model.User;
044 import com.liferay.portal.security.lang.DoPrivilegedBean;
045 import com.liferay.portal.security.lang.DoPrivilegedUtil;
046 import com.liferay.portal.service.PortletLocalServiceUtil;
047 import com.liferay.portal.service.RoleLocalServiceUtil;
048 import com.liferay.portal.servlet.NamespaceServletRequest;
049 import com.liferay.portal.servlet.SharedSessionServletRequest;
050 import com.liferay.portal.theme.ThemeDisplay;
051 import com.liferay.portal.util.PortalUtil;
052 import com.liferay.portal.util.WebKeys;
053 import com.liferay.portlet.portletconfiguration.util.PublicRenderParameterConfiguration;
054
055 import java.security.Principal;
056 import java.security.PrivilegedAction;
057
058 import java.util.ArrayList;
059 import java.util.Collections;
060 import java.util.Enumeration;
061 import java.util.HashMap;
062 import java.util.LinkedHashMap;
063 import java.util.List;
064 import java.util.Locale;
065 import java.util.Map;
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.ServletContext;
081 import javax.servlet.http.Cookie;
082 import javax.servlet.http.HttpServletRequest;
083 import javax.servlet.http.HttpSession;
084
085
091 public abstract class PortletRequestImpl implements LiferayPortletRequest {
092
093 public static PortletRequestImpl getPortletRequestImpl(
094 PortletRequest portletRequest) {
095
096 while (!(portletRequest instanceof PortletRequestImpl)) {
097 if (portletRequest instanceof DoPrivilegedBean) {
098 DoPrivilegedBean doPrivilegedBean =
099 (DoPrivilegedBean)portletRequest;
100
101 portletRequest =
102 (PortletRequest)doPrivilegedBean.getActualBean();
103 }
104 else if (portletRequest instanceof PortletRequestWrapper) {
105 PortletRequestWrapper portletRequestWrapper =
106 (PortletRequestWrapper)portletRequest;
107
108 portletRequest = portletRequestWrapper.getRequest();
109 }
110 else {
111 throw new RuntimeException(
112 "Unable to unwrap the portlet request from " +
113 portletRequest.getClass());
114 }
115 }
116
117 return (PortletRequestImpl)portletRequest;
118 }
119
120 public void cleanUp() {
121 _request.removeAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
122 _request.removeAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);
123 _request.removeAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE);
124 _request.removeAttribute(PortletRequest.LIFECYCLE_PHASE);
125 _request.removeAttribute(WebKeys.PORTLET_ID);
126 _request.removeAttribute(WebKeys.PORTLET_CONTENT);
127 }
128
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 LiferayPortletContext liferayPortletContext =
195 (LiferayPortletContext)_portletContext;
196
197 ServletContext servletContext =
198 liferayPortletContext.getServletContext();
199
200 String servletContextName = servletContext.getServletContextName();
201
202 if (ServletContextPool.containsKey(servletContextName)) {
203 servletContext = ServletContextPool.get(servletContextName);
204
205 return ContextPathUtil.getContextPath(servletContext);
206 }
207
208 return StringPool.SLASH.concat(_portletContext.getPortletContextName());
209 }
210
211 @Override
212 public Cookie[] getCookies() {
213 return _request.getCookies();
214 }
215
216 public String getETag() {
217 return null;
218 }
219
220 @Override
221 public HttpServletRequest getHttpServletRequest() {
222 return _request;
223 }
224
225 public abstract String getLifecycle();
226
227 @Override
228 public Locale getLocale() {
229 Locale locale = _locale;
230
231 if (locale == null) {
232 locale = _request.getLocale();
233 }
234
235 if (locale == null) {
236 locale = LocaleUtil.getDefault();
237 }
238
239 return locale;
240 }
241
242 @Override
243 public Enumeration<Locale> getLocales() {
244 return _request.getLocales();
245 }
246
247 public String getMethod() {
248 return _request.getMethod();
249 }
250
251 public HttpServletRequest getOriginalHttpServletRequest() {
252 return _originalRequest;
253 }
254
255 @Override
256 public String getParameter(String name) {
257 if (name == null) {
258 throw new IllegalArgumentException();
259 }
260
261 if (_portletRequestDispatcherRequest != null) {
262 return _portletRequestDispatcherRequest.getParameter(name);
263 }
264
265 return _request.getParameter(name);
266 }
267
268 @Override
269 public Map<String, String[]> getParameterMap() {
270 if (_portletRequestDispatcherRequest != null) {
271 return Collections.unmodifiableMap(
272 _portletRequestDispatcherRequest.getParameterMap());
273 }
274
275 return Collections.unmodifiableMap(_request.getParameterMap());
276 }
277
278 @Override
279 public Enumeration<String> getParameterNames() {
280 if (_portletRequestDispatcherRequest != null) {
281 return _portletRequestDispatcherRequest.getParameterNames();
282 }
283
284 return _request.getParameterNames();
285 }
286
287 @Override
288 public String[] getParameterValues(String name) {
289 if (name == null) {
290 throw new IllegalArgumentException();
291 }
292
293 if (_portletRequestDispatcherRequest != null) {
294 return _portletRequestDispatcherRequest.getParameterValues(name);
295 }
296
297 return _request.getParameterValues(name);
298 }
299
300 @Override
301 public PortalContext getPortalContext() {
302 return _portalContext;
303 }
304
305 public Portlet getPortlet() {
306 return _portlet;
307 }
308
309 public PortletContext getPortletContext() {
310 return _portletContext;
311 }
312
313 @Override
314 public PortletMode getPortletMode() {
315 return _portletMode;
316 }
317
318 public String getPortletName() {
319 return _portletName;
320 }
321
322 @Override
323 public PortletSession getPortletSession() {
324 return _session;
325 }
326
327 @Override
328 public PortletSession getPortletSession(boolean create) {
329
342
343
349
350 if (!create && _invalidSession) {
351 return null;
352 }
353
354 return _session;
355 }
356
357 @Override
358 public PortletPreferences getPreferences() {
359 return DoPrivilegedUtil.wrap(new PortletPreferencesPrivilegedAction());
360 }
361
362 public PortletPreferencesImpl getPreferencesImpl() {
363 return (PortletPreferencesImpl)_preferences;
364 }
365
366 @Override
367 public Map<String, String[]> getPrivateParameterMap() {
368 Map<String, String[]> parameterMap = null;
369
370 if (_portletRequestDispatcherRequest != null) {
371 parameterMap = _portletRequestDispatcherRequest.getParameterMap();
372 }
373 else {
374 parameterMap = _request.getParameterMap();
375 }
376
377 Map<String, String[]> privateParameterMap = null;
378
379 for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
380 String name = entry.getKey();
381
382 if (_portlet.getPublicRenderParameter(name) != null) {
383 continue;
384 }
385
386 if (privateParameterMap == null) {
387 privateParameterMap = new HashMap<String, String[]>(
388 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<String>();
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<String, String[]>(
443 parameterMap.size(), 1);
444 }
445
446 publicParameterMap.put(name, entry.getValue());
447 }
448 }
449
450 if (publicParameterMap == null) {
451 return Collections.emptyMap();
452 }
453 else {
454 return Collections.unmodifiableMap(publicParameterMap);
455 }
456 }
457
458 @Override
459 public String getRemoteUser() {
460 return _remoteUser;
461 }
462
463 @Override
464 public Map<String, String[]> getRenderParameters() {
465 return RenderParametersPool.get(_request, _plid, _portletName);
466 }
467
468 @Override
469 public String getRequestedSessionId() {
470 if (_session != null) {
471 return _session.getId();
472 }
473
474 HttpSession session = _request.getSession(false);
475
476 if (session == null) {
477 return StringPool.BLANK;
478 }
479 else {
480 return session.getId();
481 }
482 }
483
484 @Override
485 public String getResponseContentType() {
486 if (_wapTheme) {
487 return ContentTypes.XHTML_MP;
488 }
489 else {
490 return ContentTypes.TEXT_HTML;
491 }
492 }
493
494 @Override
495 public Enumeration<String> getResponseContentTypes() {
496 List<String> responseContentTypes = new ArrayList<String>();
497
498 responseContentTypes.add(getResponseContentType());
499
500 return Collections.enumeration(responseContentTypes);
501 }
502
503 @Override
504 public String getScheme() {
505 return _request.getScheme();
506 }
507
508 @Override
509 public String getServerName() {
510 return _request.getServerName();
511 }
512
513 @Override
514 public int getServerPort() {
515 return _request.getServerPort();
516 }
517
518 public LinkedHashMap<String, String> getUserInfo() {
519 return UserInfoFactory.getUserInfo(_remoteUserId, _portlet);
520 }
521
522 @Override
523 public Principal getUserPrincipal() {
524 return _userPrincipal;
525 }
526
527 @Override
528 public String getWindowID() {
529 return _portletName.concat(
530 LiferayPortletSession.LAYOUT_SEPARATOR).concat(
531 String.valueOf(_plid));
532 }
533
534 @Override
535 public WindowState getWindowState() {
536 return _windowState;
537 }
538
539 public void invalidateSession() {
540 _invalidSession = true;
541 }
542
543 public boolean isInvalidParameter(String name) {
544 if (Validator.isNull(name) ||
545 name.startsWith(PortletQName.PUBLIC_RENDER_PARAMETER_NAMESPACE) ||
546 name.startsWith(
547 PortletQName.REMOVE_PUBLIC_RENDER_PARAMETER_NAMESPACE) ||
548 PortalUtil.isReservedParameter(name)) {
549
550 return true;
551 }
552 else {
553 return false;
554 }
555 }
556
557 @Override
558 public boolean isPortletModeAllowed(PortletMode portletMode) {
559 if ((portletMode == null) || Validator.isNull(portletMode.toString())) {
560 return true;
561 }
562 else {
563 return _portlet.hasPortletMode(
564 getResponseContentType(), portletMode);
565 }
566 }
567
568 public boolean isPrivateRequestAttributes() {
569 return _portlet.isPrivateRequestAttributes();
570 }
571
572 @Override
573 public boolean isRequestedSessionIdValid() {
574 return _request.isRequestedSessionIdValid();
575 }
576
577 @Override
578 public boolean isSecure() {
579 return _request.isSecure();
580 }
581
582 public boolean isTriggeredByActionURL() {
583 return _triggeredByActionURL;
584 }
585
586 @Override
587 public boolean isUserInRole(String role) {
588 if (_remoteUserId <= 0) {
589 return false;
590 }
591
592 try {
593 long companyId = PortalUtil.getCompanyId(_request);
594
595 String roleLink = _portlet.getRoleMappers().get(role);
596
597 if (Validator.isNotNull(roleLink)) {
598 return RoleLocalServiceUtil.hasUserRole(
599 _remoteUserId, companyId, roleLink, true);
600 }
601 else {
602 return RoleLocalServiceUtil.hasUserRole(
603 _remoteUserId, companyId, role, true);
604 }
605 }
606 catch (Exception e) {
607 _log.error(e);
608 }
609
610 return _request.isUserInRole(role);
611 }
612
613 @Override
614 public boolean isWindowStateAllowed(WindowState windowState) {
615 return PortalContextImpl.isSupportedWindowState(windowState);
616 }
617
618 @Override
619 public void removeAttribute(String name) {
620 if (name == null) {
621 throw new IllegalArgumentException();
622 }
623
624 _request.removeAttribute(name);
625 }
626
627 @Override
628 public void setAttribute(String name, Object obj) {
629 if (name == null) {
630 throw new IllegalArgumentException();
631 }
632
633 if (obj == null) {
634 removeAttribute(name);
635 }
636 else {
637 _request.setAttribute(name, obj);
638 }
639 }
640
641 public void setPortletMode(PortletMode portletMode) {
642 _portletMode = portletMode;
643 }
644
645 public void setPortletRequestDispatcherRequest(HttpServletRequest request) {
646 _portletRequestDispatcherRequest = request;
647 }
648
649 public void setWindowState(WindowState windowState) {
650 _windowState = windowState;
651 }
652
653 protected void init(
654 HttpServletRequest request, Portlet portlet,
655 InvokerPortlet invokerPortlet, PortletContext portletContext,
656 WindowState windowState, PortletMode portletMode,
657 PortletPreferences preferences, long plid) {
658
659 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
660 WebKeys.THEME_DISPLAY);
661
662 _portlet = portlet;
663 _portletName = portlet.getPortletId();
664 _publicRenderParameters = PublicRenderParametersPool.get(request, plid);
665
666 String portletNamespace = PortalUtil.getPortletNamespace(_portletName);
667
668 PortletApp portletApp = portlet.getPortletApp();
669
670 boolean warFile = portletApp.isWARFile();
671
672 if (!warFile) {
673 String portletResource = ParamUtil.getString(
674 request, portletNamespace.concat("portletResource"));
675
676 if (Validator.isNotNull(portletResource)) {
677 Portlet resourcePortlet = null;
678
679 try {
680 resourcePortlet = PortletLocalServiceUtil.getPortletById(
681 themeDisplay.getCompanyId(), portletResource);
682 }
683 catch (Exception e) {
684 }
685
686 if (resourcePortlet != null) {
687 PortletApp resourcePortletApp =
688 resourcePortlet.getPortletApp();
689
690 if (resourcePortletApp.isWARFile()) {
691 warFile = true;
692 }
693 }
694 }
695 }
696
697 if (warFile) {
698 boolean portalSessionShared = !portlet.isPrivateSessionAttributes();
699
700 Portlet spiAgentPortlet = (Portlet)request.getAttribute(
701 WebKeys.SPI_AGENT_PORTLET);
702
703 if (spiAgentPortlet != null) {
704 portalSessionShared = true;
705 }
706
707 request = new SharedSessionServletRequest(
708 request, portalSessionShared);
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 =
766 new HashMap<String, String[]>();
767
768 if (getLifecycle().equals(PortletRequest.RENDER_PHASE) &&
769 !LiferayWindowState.isExclusive(request) &&
770 !LiferayWindowState.isPopUp(request)) {
771
772 RenderParametersPool.put(
773 request, plid, _portletName, renderParameters);
774 }
775
776 Map<String, String[]> parameters = request.getParameterMap();
777
778 for (Map.Entry<String, String[]> entry : parameters.entrySet()) {
779 String name = entry.getKey();
780
781 if (isInvalidParameter(name)) {
782 continue;
783 }
784
785 String[] values = entry.getValue();
786
787 if (themeDisplay.isLifecycleRender()) {
788 renderParameters.put(name, values);
789 }
790
791 if (values == null) {
792 continue;
793 }
794
795 if ((invokerPortlet != null) &&
796 invokerPortlet.isFacesPortlet()) {
797
798 if (name.startsWith(portletNamespace) ||
799 !portlet.isRequiresNamespacedParameters()) {
800
801 dynamicRequest.setParameterValues(name, values);
802 }
803 }
804 else {
805 String realName = removePortletNamespace(
806 portletNamespace, name);
807
808 if (!realName.equals(name) ||
809 !portlet.isRequiresNamespacedParameters()) {
810
811 dynamicRequest.setParameterValues(realName, values);
812 }
813 }
814 }
815 }
816 else {
817 Map<String, String[]> renderParameters = RenderParametersPool.get(
818 request, plid, _portletName);
819
820 for (Map.Entry<String, String[]> entry :
821 renderParameters.entrySet()) {
822
823 String name = entry.getKey();
824 String[] values = entry.getValue();
825
826 if ((invokerPortlet == null) ||
827 !invokerPortlet.isFacesPortlet()) {
828
829 name = removePortletNamespace(portletNamespace, name);
830 }
831
832 dynamicRequest.setParameterValues(name, values);
833 }
834 }
835
836 mergePublicRenderParameters(dynamicRequest, preferences, plid);
837
838 _request = dynamicRequest;
839 _originalRequest = request;
840 _wapTheme = BrowserSnifferUtil.isWap(_request);
841 _portlet = portlet;
842 _portalContext = new PortalContextImpl();
843 _portletContext = portletContext;
844 _windowState = windowState;
845 _portletMode = portletMode;
846 _preferences = preferences;
847 _session = new PortletSessionImpl(
848 _request.getSession(), _portletContext, _portletName, plid);
849
850 String remoteUser = request.getRemoteUser();
851
852 String userPrincipalStrategy = portlet.getUserPrincipalStrategy();
853
854 if (userPrincipalStrategy.equals(
855 PortletConstants.USER_PRINCIPAL_STRATEGY_SCREEN_NAME)) {
856
857 try {
858 User user = PortalUtil.getUser(request);
859
860 if (user != null) {
861 _remoteUser = user.getScreenName();
862 _remoteUserId = user.getUserId();
863 _userPrincipal = new ProtectedPrincipal(_remoteUser);
864 }
865 }
866 catch (Exception e) {
867 _log.error(e);
868 }
869 }
870 else {
871 long userId = PortalUtil.getUserId(request);
872
873 if ((userId > 0) && (remoteUser == null)) {
874 _remoteUser = String.valueOf(userId);
875 _remoteUserId = userId;
876 _userPrincipal = new ProtectedPrincipal(_remoteUser);
877 }
878 else {
879 _remoteUser = remoteUser;
880 _remoteUserId = GetterUtil.getLong(remoteUser);
881 _userPrincipal = request.getUserPrincipal();
882 }
883 }
884
885 _locale = themeDisplay.getLocale();
886 _plid = plid;
887 }
888
889 protected void mergePublicRenderParameters(
890 DynamicServletRequest dynamicRequest, PortletPreferences preferences,
891 long plid) {
892
893 Enumeration<PublicRenderParameter> publicRenderParameters =
894 Collections.enumeration(_portlet.getPublicRenderParameters());
895
896 while (publicRenderParameters.hasMoreElements()) {
897 PublicRenderParameter publicRenderParameter =
898 publicRenderParameters.nextElement();
899
900 String ignoreKey = PublicRenderParameterConfiguration.getIgnoreKey(
901 publicRenderParameter);
902
903 boolean ignoreValue = GetterUtil.getBoolean(
904 preferences.getValue(ignoreKey, null));
905
906 if (ignoreValue) {
907 continue;
908 }
909
910 String mappingKey =
911 PublicRenderParameterConfiguration.getMappingKey(
912 publicRenderParameter);
913
914 String mappingValue = GetterUtil.getString(
915 preferences.getValue(mappingKey, null));
916
917 HttpServletRequest request =
918 (HttpServletRequest)dynamicRequest.getRequest();
919
920 String[] newValues = request.getParameterValues(mappingValue);
921
922 if ((newValues != null) && (newValues.length != 0)) {
923 newValues = ArrayUtil.remove(newValues, StringPool.NULL);
924 }
925
926 String name = publicRenderParameter.getIdentifier();
927
928 if (ArrayUtil.isEmpty(newValues)) {
929 QName qName = publicRenderParameter.getQName();
930
931 String[] values = _publicRenderParameters.get(
932 PortletQNameUtil.getPublicRenderParameterName(qName));
933
934 if (ArrayUtil.isEmpty(values) || Validator.isNull(values[0])) {
935 continue;
936 }
937
938 if (dynamicRequest.getParameter(name) == null) {
939 dynamicRequest.setParameterValues(name, values);
940 }
941 }
942 else {
943 dynamicRequest.setParameterValues(name, newValues);
944 }
945 }
946 }
947
948 protected String removePortletNamespace(
949 String portletNamespace, String name) {
950
951 if (name.startsWith(portletNamespace)) {
952 name = name.substring(portletNamespace.length());
953 }
954
955 return name;
956 }
957
958 private static Log _log = LogFactoryUtil.getLog(PortletRequestImpl.class);
959
960 private boolean _invalidSession;
961 private Locale _locale;
962 private HttpServletRequest _originalRequest;
963 private long _plid;
964 private PortalContext _portalContext;
965 private Portlet _portlet;
966 private PortletContext _portletContext;
967 private PortletMode _portletMode;
968 private String _portletName;
969 private HttpServletRequest _portletRequestDispatcherRequest;
970 private PortletPreferences _preferences;
971 private Profile _profile;
972 private Map<String, String[]> _publicRenderParameters;
973 private String _remoteUser;
974 private long _remoteUserId;
975 private HttpServletRequest _request;
976 private PortletSessionImpl _session;
977 private boolean _triggeredByActionURL;
978 private Principal _userPrincipal;
979 private boolean _wapTheme;
980 private WindowState _windowState;
981
982 private class PortletPreferencesPrivilegedAction
983 implements PrivilegedAction<PortletPreferences> {
984
985 @Override
986 public PortletPreferences run() {
987 return new PortletPreferencesWrapper(
988 getPreferencesImpl(), getLifecycle());
989 }
990
991 }
992
993 }