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.RoleLocalServiceUtil;
047 import com.liferay.portal.servlet.NamespaceServletRequest;
048 import com.liferay.portal.servlet.SharedSessionServletRequest;
049 import com.liferay.portal.theme.ThemeDisplay;
050 import com.liferay.portal.util.PortalUtil;
051 import com.liferay.portal.util.WebKeys;
052 import com.liferay.portlet.portletconfiguration.util.PublicRenderParameterConfiguration;
053
054 import java.security.Principal;
055 import java.security.PrivilegedAction;
056
057 import java.util.ArrayList;
058 import java.util.Collections;
059 import java.util.Enumeration;
060 import java.util.HashMap;
061 import java.util.LinkedHashMap;
062 import java.util.List;
063 import java.util.Locale;
064 import java.util.Map;
065
066 import javax.ccpp.Profile;
067
068 import javax.portlet.PortalContext;
069 import javax.portlet.PortletConfig;
070 import javax.portlet.PortletContext;
071 import javax.portlet.PortletMode;
072 import javax.portlet.PortletPreferences;
073 import javax.portlet.PortletRequest;
074 import javax.portlet.PortletResponse;
075 import javax.portlet.PortletSession;
076 import javax.portlet.WindowState;
077 import javax.portlet.filter.PortletRequestWrapper;
078
079 import javax.servlet.ServletContext;
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 public void defineObjects(
129 PortletConfig portletConfig, PortletResponse portletResponse) {
130
131 LiferayPortletConfig liferayPortletConfig =
132 (LiferayPortletConfig)portletConfig;
133
134 setAttribute(WebKeys.PORTLET_ID, liferayPortletConfig.getPortletId());
135 setAttribute(JavaConstants.JAVAX_PORTLET_CONFIG, portletConfig);
136 setAttribute(JavaConstants.JAVAX_PORTLET_REQUEST, this);
137 setAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE, portletResponse);
138 setAttribute(PortletRequest.LIFECYCLE_PHASE, getLifecycle());
139 }
140
141 @Override
142 public Object getAttribute(String name) {
143 if (name == null) {
144 throw new IllegalArgumentException();
145 }
146
147 if (name.equals(PortletRequest.CCPP_PROFILE)) {
148 return getCCPPProfile();
149 }
150 else if (name.equals(PortletRequest.USER_INFO)) {
151 Object value = getUserInfo();
152
153 if (value != null) {
154 return value;
155 }
156 }
157
158 return _request.getAttribute(name);
159 }
160
161 @Override
162 public Enumeration<String> getAttributeNames() {
163 List<String> names = new ArrayList<String>();
164
165 Enumeration<String> enu = _request.getAttributeNames();
166
167 while (enu.hasMoreElements()) {
168 String name = enu.nextElement();
169
170 if (!name.equals(JavaConstants.JAVAX_SERVLET_INCLUDE_PATH_INFO)) {
171 names.add(name);
172 }
173 }
174
175 return Collections.enumeration(names);
176 }
177
178 @Override
179 public String getAuthType() {
180 return _request.getAuthType();
181 }
182
183 public Profile getCCPPProfile() {
184 if (_profile == null) {
185 _profile = PortalProfileFactory.getCCPPProfile(_request);
186 }
187
188 return _profile;
189 }
190
191 @Override
192 public String getContextPath() {
193 LiferayPortletContext liferayPortletContext =
194 (LiferayPortletContext)_portletContext;
195
196 ServletContext servletContext =
197 liferayPortletContext.getServletContext();
198
199 String servletContextName = servletContext.getServletContextName();
200
201 if (ServletContextPool.containsKey(servletContextName)) {
202 servletContext = ServletContextPool.get(servletContextName);
203
204 return ContextPathUtil.getContextPath(servletContext);
205 }
206
207 return StringPool.SLASH.concat(_portletContext.getPortletContextName());
208 }
209
210 @Override
211 public Cookie[] getCookies() {
212 return _request.getCookies();
213 }
214
215 public String getETag() {
216 return null;
217 }
218
219 @Override
220 public HttpServletRequest getHttpServletRequest() {
221 return _request;
222 }
223
224 public abstract String getLifecycle();
225
226 @Override
227 public Locale getLocale() {
228 Locale locale = _locale;
229
230 if (locale == null) {
231 locale = _request.getLocale();
232 }
233
234 if (locale == null) {
235 locale = LocaleUtil.getDefault();
236 }
237
238 return locale;
239 }
240
241 @Override
242 public Enumeration<Locale> getLocales() {
243 return _request.getLocales();
244 }
245
246 public String getMethod() {
247 return _request.getMethod();
248 }
249
250 public HttpServletRequest getOriginalHttpServletRequest() {
251 return _originalRequest;
252 }
253
254 @Override
255 public String getParameter(String name) {
256 if (name == null) {
257 throw new IllegalArgumentException();
258 }
259
260 if (_portletRequestDispatcherRequest != null) {
261 return _portletRequestDispatcherRequest.getParameter(name);
262 }
263
264 return _request.getParameter(name);
265 }
266
267 @Override
268 public Map<String, String[]> getParameterMap() {
269 if (_portletRequestDispatcherRequest != null) {
270 return Collections.unmodifiableMap(
271 _portletRequestDispatcherRequest.getParameterMap());
272 }
273
274 return Collections.unmodifiableMap(_request.getParameterMap());
275 }
276
277 @Override
278 public Enumeration<String> getParameterNames() {
279 if (_portletRequestDispatcherRequest != null) {
280 return _portletRequestDispatcherRequest.getParameterNames();
281 }
282
283 return _request.getParameterNames();
284 }
285
286 @Override
287 public String[] getParameterValues(String name) {
288 if (name == null) {
289 throw new IllegalArgumentException();
290 }
291
292 if (_portletRequestDispatcherRequest != null) {
293 return _portletRequestDispatcherRequest.getParameterValues(name);
294 }
295
296 return _request.getParameterValues(name);
297 }
298
299 @Override
300 public PortalContext getPortalContext() {
301 return _portalContext;
302 }
303
304 public Portlet getPortlet() {
305 return _portlet;
306 }
307
308 public PortletContext getPortletContext() {
309 return _portletContext;
310 }
311
312 @Override
313 public PortletMode getPortletMode() {
314 return _portletMode;
315 }
316
317 public String getPortletName() {
318 return _portletName;
319 }
320
321 @Override
322 public PortletSession getPortletSession() {
323 return _session;
324 }
325
326 @Override
327 public PortletSession getPortletSession(boolean create) {
328
341
342
348
349 if (!create && _invalidSession) {
350 return null;
351 }
352
353 return _session;
354 }
355
356 @Override
357 public PortletPreferences getPreferences() {
358 return DoPrivilegedUtil.wrap(new PortletPreferencesPrivilegedAction());
359 }
360
361 public PortletPreferencesImpl getPreferencesImpl() {
362 return (PortletPreferencesImpl)_preferences;
363 }
364
365 @Override
366 public Map<String, String[]> getPrivateParameterMap() {
367 Map<String, String[]> parameterMap = null;
368
369 if (_portletRequestDispatcherRequest != null) {
370 parameterMap = _portletRequestDispatcherRequest.getParameterMap();
371 }
372 else {
373 parameterMap = _request.getParameterMap();
374 }
375
376 Map<String, String[]> privateParameterMap = null;
377
378 for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
379 String name = entry.getKey();
380
381 if (_portlet.getPublicRenderParameter(name) != null) {
382 continue;
383 }
384
385 if (privateParameterMap == null) {
386 privateParameterMap = new HashMap<String, String[]>(
387 parameterMap.size(), 1);
388 }
389
390 privateParameterMap.put(name, entry.getValue());
391 }
392
393 if (privateParameterMap == null) {
394 return Collections.emptyMap();
395 }
396
397 return Collections.unmodifiableMap(privateParameterMap);
398 }
399
400 @Override
401 public Enumeration<String> getProperties(String name) {
402 List<String> values = new ArrayList<String>();
403
404 String value = _portalContext.getProperty(name);
405
406 if (value != null) {
407 values.add(value);
408 }
409
410 return Collections.enumeration(values);
411 }
412
413 @Override
414 public String getProperty(String name) {
415 return _portalContext.getProperty(name);
416 }
417
418 @Override
419 public Enumeration<String> getPropertyNames() {
420 return _portalContext.getPropertyNames();
421 }
422
423 @Override
424 public Map<String, String[]> getPublicParameterMap() {
425 Map<String, String[]> parameterMap = null;
426
427 if (_portletRequestDispatcherRequest != null) {
428 parameterMap = _portletRequestDispatcherRequest.getParameterMap();
429 }
430 else {
431 parameterMap = _request.getParameterMap();
432 }
433
434 Map<String, String[]> publicParameterMap = null;
435
436 for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
437 String name = entry.getKey();
438
439 if (_portlet.getPublicRenderParameter(name) != null) {
440 if (publicParameterMap == null) {
441 publicParameterMap = new HashMap<String, String[]>(
442 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 else {
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
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 else {
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
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 String portletNamespace = PortalUtil.getPortletNamespace(_portletName);
668
669 boolean portalSessionShared = false;
670
671 PortletApp portletApp = portlet.getPortletApp();
672
673 if (portletApp.isWARFile() && !portlet.isPrivateSessionAttributes()) {
674 portalSessionShared = true;
675 }
676
677 request = new SharedSessionServletRequest(request, portalSessionShared);
678
679 String dynamicQueryString = (String)request.getAttribute(
680 DynamicServletRequest.DYNAMIC_QUERY_STRING);
681
682 if (dynamicQueryString != null) {
683 request.removeAttribute(DynamicServletRequest.DYNAMIC_QUERY_STRING);
684
685 request = DynamicServletRequest.addQueryString(
686 request, dynamicQueryString, true);
687 }
688
689 DynamicServletRequest dynamicRequest = null;
690
691 if (portlet.isPrivateRequestAttributes()) {
692 dynamicRequest = new NamespaceServletRequest(
693 request, portletNamespace, portletNamespace, false);
694 }
695 else {
696 dynamicRequest = new DynamicServletRequest(request, false);
697 }
698
699 boolean portletFocus = false;
700
701 String ppid = ParamUtil.getString(request, "p_p_id");
702
703 boolean windowStateRestoreCurrentView = ParamUtil.getBoolean(
704 request, "p_p_state_rcv");
705
706 if (_portletName.equals(ppid) &&
707 !(windowStateRestoreCurrentView &&
708 portlet.isRestoreCurrentView())) {
709
710
711
712 if (themeDisplay.isLifecycleRender() ||
713 themeDisplay.isLifecycleResource()) {
714
715
716
717 portletFocus = true;
718 }
719 else if (themeDisplay.isLifecycleAction()) {
720 _triggeredByActionURL = true;
721
722 if (getLifecycle().equals(PortletRequest.ACTION_PHASE)) {
723
724
725
726
727 portletFocus = true;
728 }
729 }
730 }
731
732 if (portletFocus) {
733 Map<String, String[]> renderParameters =
734 new HashMap<String, String[]>();
735
736 if (getLifecycle().equals(PortletRequest.RENDER_PHASE) &&
737 !LiferayWindowState.isExclusive(request) &&
738 !LiferayWindowState.isPopUp(request)) {
739
740 RenderParametersPool.put(
741 request, plid, _portletName, renderParameters);
742 }
743
744 Map<String, String[]> parameters = request.getParameterMap();
745
746 for (Map.Entry<String, String[]> entry : parameters.entrySet()) {
747 String name = entry.getKey();
748
749 if (isInvalidParameter(name)) {
750 continue;
751 }
752
753 String[] values = entry.getValue();
754
755 if (themeDisplay.isLifecycleRender()) {
756 renderParameters.put(name, values);
757 }
758
759 if (values == null) {
760 continue;
761 }
762
763 String realName = removePortletNamespace(
764 invokerPortlet, portletNamespace, name);
765
766 if (!realName.equals(name) ||
767 !portlet.isRequiresNamespacedParameters()) {
768
769 dynamicRequest.setParameterValues(realName, values);
770 }
771 }
772 }
773 else {
774 Map<String, String[]> renderParameters = RenderParametersPool.get(
775 request, plid, _portletName);
776
777 for (Map.Entry<String, String[]> entry :
778 renderParameters.entrySet()) {
779
780 String name = entry.getKey();
781 String[] values = entry.getValue();
782
783 name = removePortletNamespace(
784 invokerPortlet, portletNamespace, name);
785
786 dynamicRequest.setParameterValues(name, values);
787 }
788 }
789
790 mergePublicRenderParameters(dynamicRequest, preferences, plid);
791
792 _request = dynamicRequest;
793 _originalRequest = request;
794 _wapTheme = BrowserSnifferUtil.isWap(_request);
795 _portlet = portlet;
796 _portalContext = new PortalContextImpl();
797 _portletContext = portletContext;
798 _windowState = windowState;
799 _portletMode = portletMode;
800 _preferences = preferences;
801 _session = new PortletSessionImpl(
802 _request.getSession(), _portletContext, _portletName, plid);
803
804 String remoteUser = request.getRemoteUser();
805
806 String userPrincipalStrategy = portlet.getUserPrincipalStrategy();
807
808 if (userPrincipalStrategy.equals(
809 PortletConstants.USER_PRINCIPAL_STRATEGY_SCREEN_NAME)) {
810
811 try {
812 User user = PortalUtil.getUser(request);
813
814 if (user != null) {
815 _remoteUser = user.getScreenName();
816 _remoteUserId = user.getUserId();
817 _userPrincipal = new ProtectedPrincipal(_remoteUser);
818 }
819 }
820 catch (Exception e) {
821 _log.error(e);
822 }
823 }
824 else {
825 long userId = PortalUtil.getUserId(request);
826
827 if ((userId > 0) && (remoteUser == null)) {
828 _remoteUser = String.valueOf(userId);
829 _remoteUserId = userId;
830 _userPrincipal = new ProtectedPrincipal(_remoteUser);
831 }
832 else {
833 _remoteUser = remoteUser;
834 _remoteUserId = GetterUtil.getLong(remoteUser);
835 _userPrincipal = request.getUserPrincipal();
836 }
837 }
838
839 _locale = themeDisplay.getLocale();
840 _plid = plid;
841 }
842
843 protected void mergePublicRenderParameters(
844 DynamicServletRequest dynamicRequest, PortletPreferences preferences,
845 long plid) {
846
847 Enumeration<PublicRenderParameter> publicRenderParameters =
848 Collections.enumeration(_portlet.getPublicRenderParameters());
849
850 while (publicRenderParameters.hasMoreElements()) {
851 PublicRenderParameter publicRenderParameter =
852 publicRenderParameters.nextElement();
853
854 String ignoreKey = PublicRenderParameterConfiguration.getIgnoreKey(
855 publicRenderParameter);
856
857 boolean ignoreValue = GetterUtil.getBoolean(
858 preferences.getValue(ignoreKey, null));
859
860 if (ignoreValue) {
861 continue;
862 }
863
864 String mappingKey =
865 PublicRenderParameterConfiguration.getMappingKey(
866 publicRenderParameter);
867
868 String mappingValue = GetterUtil.getString(
869 preferences.getValue(mappingKey, null));
870
871 HttpServletRequest request =
872 (HttpServletRequest)dynamicRequest.getRequest();
873
874 String[] newValues = request.getParameterValues(mappingValue);
875
876 if ((newValues != null) && (newValues.length != 0)) {
877 newValues = ArrayUtil.remove(newValues, StringPool.NULL);
878 }
879
880 String name = publicRenderParameter.getIdentifier();
881
882 if ((newValues == null) || (newValues.length == 0)) {
883 QName qName = publicRenderParameter.getQName();
884
885 String[] values = _publicRenderParameters.get(
886 PortletQNameUtil.getPublicRenderParameterName(qName));
887
888 if ((values == null) || (values.length == 0) ||
889 Validator.isNull(values[0])) {
890
891 continue;
892 }
893
894 if (dynamicRequest.getParameter(name) == null) {
895 dynamicRequest.setParameterValues(name, values);
896 }
897 }
898 else {
899 dynamicRequest.setParameterValues(name, newValues);
900 }
901 }
902 }
903
904 protected String removePortletNamespace(
905 InvokerPortlet invokerPortlet, String portletNamespace, String name) {
906
907 if (name.startsWith(portletNamespace) &&
908 ((invokerPortlet == null) || !invokerPortlet.isFacesPortlet())) {
909
910 name = name.substring(portletNamespace.length());
911 }
912
913 return name;
914 }
915
916 private static Log _log = LogFactoryUtil.getLog(PortletRequestImpl.class);
917
918 private boolean _invalidSession;
919 private Locale _locale;
920 private HttpServletRequest _originalRequest;
921 private long _plid;
922 private PortalContext _portalContext;
923 private Portlet _portlet;
924 private PortletContext _portletContext;
925 private PortletMode _portletMode;
926 private String _portletName;
927 private HttpServletRequest _portletRequestDispatcherRequest;
928 private PortletPreferences _preferences;
929 private Profile _profile;
930 private Map<String, String[]> _publicRenderParameters;
931 private String _remoteUser;
932 private long _remoteUserId;
933 private HttpServletRequest _request;
934 private PortletSessionImpl _session;
935 private boolean _triggeredByActionURL;
936 private Principal _userPrincipal;
937 private boolean _wapTheme;
938 private WindowState _windowState;
939
940 private class PortletPreferencesPrivilegedAction
941 implements PrivilegedAction<PortletPreferences> {
942
943 @Override
944 public PortletPreferences run() {
945 return new PortletPreferencesWrapper(
946 getPreferencesImpl(), getLifecycle());
947 }
948
949 }
950
951 }