1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.util;
16  
17  import com.liferay.portal.kernel.dao.db.DB;
18  import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
19  import com.liferay.portal.kernel.exception.PortalException;
20  import com.liferay.portal.kernel.exception.SystemException;
21  import com.liferay.portal.kernel.upload.UploadPortletRequest;
22  import com.liferay.portal.kernel.upload.UploadServletRequest;
23  import com.liferay.portal.kernel.util.KeyValuePair;
24  import com.liferay.portal.model.BaseModel;
25  import com.liferay.portal.model.Company;
26  import com.liferay.portal.model.Layout;
27  import com.liferay.portal.model.LayoutSet;
28  import com.liferay.portal.model.Portlet;
29  import com.liferay.portal.model.Resource;
30  import com.liferay.portal.model.ResourcePermission;
31  import com.liferay.portal.model.User;
32  import com.liferay.portal.theme.ThemeDisplay;
33  import com.liferay.portlet.expando.model.ExpandoBridge;
34  
35  import java.io.IOException;
36  import java.io.Serializable;
37  
38  import java.sql.SQLException;
39  
40  import java.util.Date;
41  import java.util.List;
42  import java.util.Locale;
43  import java.util.Map;
44  import java.util.Properties;
45  import java.util.TimeZone;
46  
47  import javax.portlet.ActionRequest;
48  import javax.portlet.ActionResponse;
49  import javax.portlet.PortletMode;
50  import javax.portlet.PortletPreferences;
51  import javax.portlet.PortletRequest;
52  import javax.portlet.PortletResponse;
53  import javax.portlet.PreferencesValidator;
54  import javax.portlet.RenderRequest;
55  import javax.portlet.ValidatorException;
56  import javax.portlet.WindowState;
57  
58  import javax.servlet.ServletContext;
59  import javax.servlet.ServletException;
60  import javax.servlet.http.HttpServletRequest;
61  import javax.servlet.http.HttpServletResponse;
62  import javax.servlet.http.HttpSession;
63  import javax.servlet.jsp.PageContext;
64  
65  /**
66   * <a href="PortalUtil.java.html"><b><i>View Source</i></b></a>
67   *
68   * @author Brian Wing Shun Chan
69   * @author Eduardo Lundgren
70   */
71  public class PortalUtil {
72  
73      /**
74       * Adds the description for a page. This appends to the existing page
75       * description.
76       */
77      public static void addPageDescription(
78          String description, HttpServletRequest request) {
79  
80          getPortal().addPageDescription(description, request);
81      }
82  
83      /**
84       * Adds the keywords for a page. This appends to the existing page keywords.
85       */
86      public static void addPageKeywords(
87          String keywords, HttpServletRequest request) {
88  
89          getPortal().addPageKeywords(keywords, request);
90      }
91  
92      /**
93       * Adds the subtitle for a page. This appends to the existing page subtitle.
94       */
95      public static void addPageSubtitle(
96          String subtitle, HttpServletRequest request) {
97  
98          getPortal().addPageSubtitle(subtitle, request);
99      }
100 
101     /**
102      * Adds the whole title for a page. This appends to the existing page whole
103      * title.
104      */
105     public static void addPageTitle(String title, HttpServletRequest request) {
106         getPortal().addPageTitle(title, request);
107     }
108 
109     public static void addPortletBreadcrumbEntry(
110         HttpServletRequest request, String title, String url) {
111 
112         getPortal().addPortletBreadcrumbEntry(request, title, url);
113     }
114 
115     public static void clearRequestParameters(RenderRequest renderRequest) {
116         getPortal().clearRequestParameters(renderRequest);
117     }
118 
119     public static void copyRequestParameters(
120         ActionRequest actionRequest, ActionResponse actionResponse) {
121 
122         getPortal().copyRequestParameters(actionRequest, actionResponse);
123     }
124 
125     public static String escapeRedirect(String url) {
126         return getPortal().escapeRedirect(url);
127     }
128 
129     public static BaseModel<?> getBaseModel(Resource resource)
130         throws PortalException, SystemException {
131 
132         return getPortal().getBaseModel(resource);
133     }
134 
135     public static BaseModel<?> getBaseModel(
136             ResourcePermission resourcePermission)
137         throws PortalException, SystemException {
138 
139         return getPortal().getBaseModel(resourcePermission);
140     }
141 
142     public static BaseModel<?> getBaseModel(String modelName, String primKey)
143         throws PortalException, SystemException {
144 
145         return getPortal().getBaseModel(modelName, primKey);
146     }
147 
148     public static long getBasicAuthUserId(HttpServletRequest request)
149         throws PortalException, SystemException {
150 
151         return getPortal().getBasicAuthUserId(request);
152     }
153 
154     public static long getBasicAuthUserId(
155             HttpServletRequest request, long companyId)
156         throws PortalException, SystemException {
157 
158         return getPortal().getBasicAuthUserId(request, companyId);
159     }
160 
161     /**
162      * @deprecated {@link #getCDNHost(boolean)}
163      */
164     public static String getCDNHost() {
165         return getPortal().getCDNHost();
166     }
167 
168     public static String getCDNHost(boolean secure) {
169         return getPortal().getCDNHost(secure);
170     }
171 
172     public static String getCDNHostHttp() {
173         return getPortal().getCDNHostHttp();
174     }
175 
176     public static String getCDNHostHttps() {
177         return getPortal().getCDNHostHttps();
178     }
179 
180     public static String getClassName(long classNameId) {
181         return getPortal().getClassName(classNameId);
182     }
183 
184     public static long getClassNameId(Class<?> classObj) {
185         return getPortal().getClassNameId(classObj);
186     }
187 
188     public static long getClassNameId(String value) {
189         return getPortal().getClassNameId(value);
190     }
191 
192     public static String getClassNamePortletId(String className) {
193         return getPortal().getClassNamePortletId(className);
194     }
195 
196     public static String getCommunityLoginURL(ThemeDisplay themeDisplay)
197         throws PortalException, SystemException {
198 
199         return getPortal().getCommunityLoginURL(themeDisplay);
200     }
201 
202     public static String[] getCommunityPermissions(HttpServletRequest request) {
203         return getPortal().getCommunityPermissions(request);
204     }
205 
206     public static String[] getCommunityPermissions(
207         PortletRequest portletRequest) {
208 
209         return getPortal().getCommunityPermissions(portletRequest);
210     }
211 
212     public static Company getCompany(HttpServletRequest request)
213         throws PortalException, SystemException {
214 
215         return getPortal().getCompany(request);
216     }
217 
218     public static Company getCompany(PortletRequest portletRequest)
219         throws PortalException, SystemException {
220 
221         return getPortal().getCompany(portletRequest);
222     }
223 
224     public static long getCompanyId(HttpServletRequest request) {
225         return getPortal().getCompanyId(request);
226     }
227 
228     public static long getCompanyId(PortletRequest portletRequest) {
229         return getPortal().getCompanyId(portletRequest);
230     }
231 
232     public static long[] getCompanyIds() {
233         return getPortal().getCompanyIds();
234     }
235 
236     public static String getComputerAddress() {
237         return getPortal().getComputerAddress();
238     }
239 
240     public static String getComputerName() {
241         return getPortal().getComputerName();
242     }
243 
244     public static String getControlPanelCategory(
245             String portletId, ThemeDisplay themeDisplay)
246         throws SystemException {
247 
248         return getPortal().getControlPanelCategory(portletId, themeDisplay);
249     }
250 
251     public static String getControlPanelFullURL(
252             long scopeGroupId, String ppid, Map<String, String[]> params)
253         throws PortalException, SystemException {
254 
255         return getPortal().getControlPanelFullURL(scopeGroupId, ppid, params);
256     }
257 
258     public static List<Portlet> getControlPanelPortlets(
259             String category, ThemeDisplay themeDisplay)
260         throws SystemException {
261 
262         return getPortal().getControlPanelPortlets(
263             category, themeDisplay);
264     }
265 
266     public static String getCurrentCompleteURL(HttpServletRequest request) {
267         return getPortal().getCurrentCompleteURL(request);
268     }
269 
270     public static String getCurrentURL(HttpServletRequest request) {
271         return getPortal().getCurrentURL(request);
272     }
273 
274     public static String getCurrentURL(PortletRequest portletRequest) {
275         return getPortal().getCurrentURL(portletRequest);
276     }
277 
278     public static String getCustomSQLFunctionIsNotNull() {
279         return getPortal().getCustomSQLFunctionIsNotNull();
280     }
281 
282     public static String getCustomSQLFunctionIsNull() {
283         return getPortal().getCustomSQLFunctionIsNull();
284     }
285 
286     public static Date getDate(
287             int month, int day, int year, int hour, int min, PortalException pe)
288         throws PortalException {
289 
290         return getPortal().getDate(month, day, year, hour, min, pe);
291     }
292 
293     public static Date getDate(
294             int month, int day, int year, int hour, int min, TimeZone timeZone,
295             PortalException pe)
296         throws PortalException {
297 
298         return getPortal().getDate(month, day, year, hour, min, timeZone, pe);
299     }
300 
301     public static Date getDate(int month, int day, int year, PortalException pe)
302         throws PortalException {
303 
304         return getPortal().getDate(month, day, year, pe);
305     }
306 
307     public static Date getDate(
308             int month, int day, int year, TimeZone timeZone, PortalException pe)
309         throws PortalException {
310 
311         return getPortal().getDate(month, day, year, timeZone, pe);
312     }
313 
314     /**
315      * @deprecated {@link DBFactoryUtil#getDB()}
316      */
317     public static DB getDB() {
318         return DBFactoryUtil.getDB();
319     }
320 
321     public static long getDefaultCompanyId() {
322         return getPortal().getDefaultCompanyId();
323     }
324 
325     public static Map<String, Serializable> getExpandoBridgeAttributes(
326             ExpandoBridge expandoBridge, PortletRequest portletRequest)
327         throws PortalException, SystemException {
328 
329         return getPortal().getExpandoBridgeAttributes(
330             expandoBridge, portletRequest);
331     }
332 
333     public static String getFirstPageLayoutTypes(PageContext pageContext) {
334         return getPortal().getFirstPageLayoutTypes(pageContext);
335     }
336 
337     public static String getGlobalLibDir() {
338         return getPortal().getGlobalLibDir();
339     }
340 
341     public static String getGoogleGadgetURL(
342         Portlet portlet, ThemeDisplay themeDisplay) {
343 
344         return getPortal().getGoogleGadgetURL(portlet, themeDisplay);
345     }
346 
347     public static String[] getGuestPermissions(HttpServletRequest request) {
348         return getPortal().getGuestPermissions(request);
349     }
350 
351     public static String[] getGuestPermissions(PortletRequest portletRequest) {
352         return getPortal().getGuestPermissions(portletRequest);
353     }
354 
355     public static String getHomeURL(HttpServletRequest request)
356         throws PortalException, SystemException {
357 
358         return getPortal().getHomeURL(request);
359     }
360 
361     public static String getHost(HttpServletRequest request) {
362         return getPortal().getHost(request);
363     }
364 
365     public static String getHost(PortletRequest portletRequest) {
366         return getPortal().getHost(portletRequest);
367     }
368 
369     public static HttpServletRequest getHttpServletRequest(
370         PortletRequest portletRequest) {
371 
372         return getPortal().getHttpServletRequest(portletRequest);
373     }
374 
375     public static HttpServletResponse getHttpServletResponse(
376         PortletResponse portletResponse) {
377 
378         return getPortal().getHttpServletResponse(portletResponse);
379     }
380 
381     public static String getJsSafePortletId(String portletId) {
382         return getPortal().getJsSafePortletId(portletId);
383     }
384 
385     public static String getLayoutActualURL(Layout layout) {
386         return getPortal().getLayoutActualURL(layout);
387     }
388 
389     public static String getLayoutActualURL(Layout layout, String mainPath) {
390         return getPortal().getLayoutActualURL(layout, mainPath);
391     }
392 
393     public static String getLayoutActualURL(
394             long groupId, boolean privateLayout, String mainPath,
395             String friendlyURL)
396         throws PortalException, SystemException {
397 
398         return getPortal().getLayoutActualURL(
399             groupId, privateLayout, mainPath, friendlyURL);
400     }
401 
402     public static String getLayoutActualURL(
403             long groupId, boolean privateLayout, String mainPath,
404             String friendlyURL, Map<String, String[]> params)
405         throws PortalException, SystemException {
406 
407         return getPortal().getLayoutActualURL(
408             groupId, privateLayout, mainPath, friendlyURL, params);
409     }
410 
411     public static String getLayoutEditPage(Layout layout) {
412         return getPortal().getLayoutEditPage(layout);
413     }
414 
415     public static String getLayoutFriendlyURL(
416         Layout layout, ThemeDisplay themeDisplay) {
417 
418         return getPortal().getLayoutFriendlyURL(layout, themeDisplay);
419     }
420 
421     public static String getLayoutFriendlyURL(
422         Layout layout, ThemeDisplay themeDisplay, Locale locale) {
423 
424         return getPortal().getLayoutFriendlyURL(layout, themeDisplay, locale);
425     }
426 
427     public static String getLayoutFullURL(
428         Layout layout, ThemeDisplay themeDisplay) {
429 
430         return getPortal().getLayoutFullURL(layout, themeDisplay);
431     }
432 
433     public static String getLayoutFullURL(
434         Layout layout, ThemeDisplay themeDisplay, boolean doAsUser) {
435 
436         return getPortal().getLayoutFullURL(layout, themeDisplay, doAsUser);
437     }
438 
439     public static String getLayoutFullURL(long groupId, String portletId)
440         throws PortalException, SystemException {
441 
442         return getPortal().getLayoutFullURL(groupId, portletId);
443     }
444 
445     public static String getLayoutFullURL(ThemeDisplay themeDisplay) {
446         return getPortal().getLayoutFullURL(themeDisplay);
447     }
448 
449     public static String getLayoutSetFriendlyURL(
450             LayoutSet layoutSet, ThemeDisplay themeDisplay)
451         throws PortalException, SystemException {
452 
453         return getPortal().getLayoutSetFriendlyURL(layoutSet, themeDisplay);
454     }
455 
456     public static String getLayoutTarget(Layout layout) {
457         return getPortal().getLayoutTarget(layout);
458     }
459 
460     public static String getLayoutURL(
461         Layout layout, ThemeDisplay themeDisplay) {
462 
463         return getPortal().getLayoutURL(layout, themeDisplay);
464     }
465 
466     public static String getLayoutURL(
467         Layout layout, ThemeDisplay themeDisplay, boolean doAsUser) {
468 
469         return getPortal().getLayoutURL(layout, themeDisplay, doAsUser);
470     }
471 
472     public static String getLayoutURL(ThemeDisplay themeDisplay) {
473         return getPortal().getLayoutURL(themeDisplay);
474     }
475 
476     public static String getLayoutViewPage(Layout layout) {
477         return getPortal().getLayoutViewPage(layout);
478     }
479 
480     public static Locale getLocale(HttpServletRequest request) {
481         return getPortal().getLocale(request);
482     }
483 
484     public static Locale getLocale(RenderRequest renderRequest) {
485         return getPortal().getLocale(renderRequest);
486     }
487 
488     /**
489      * @deprecated {@link #getBaseModel(Resource)}
490      */
491     public static BaseModel<?> getModel(Resource resource)
492         throws PortalException, SystemException {
493 
494         return getPortal().getBaseModel(resource);
495     }
496 
497     /**
498      * @deprecated {@link #getBaseModel(ResourcePermission)}
499      */
500     public static BaseModel<?> getModel(ResourcePermission resourcePermission)
501         throws PortalException, SystemException {
502 
503         return getPortal().getBaseModel(resourcePermission);
504     }
505 
506     /**
507      * @deprecated {@link #getBaseModel(String, String)}
508      */
509     public static BaseModel<?> getModel(String modelName, String primKey)
510         throws PortalException, SystemException {
511 
512         return getPortal().getBaseModel(modelName, primKey);
513     }
514 
515     public static String getNetvibesURL(
516         Portlet portlet, ThemeDisplay themeDisplay) {
517 
518         return getPortal().getNetvibesURL(portlet, themeDisplay);
519     }
520 
521     public static HttpServletRequest getOriginalServletRequest(
522         HttpServletRequest request) {
523 
524         return getPortal().getOriginalServletRequest(request);
525     }
526 
527     public static long getParentGroupId(long scopeGroupId)
528         throws PortalException, SystemException {
529 
530         return getPortal().getParentGroupId(scopeGroupId);
531     }
532 
533     public static String getPathContext() {
534         return getPortal().getPathContext();
535     }
536 
537     public static String getPathFriendlyURLPrivateGroup() {
538         return getPortal().getPathFriendlyURLPrivateGroup();
539     }
540 
541     public static String getPathFriendlyURLPrivateUser() {
542         return getPortal().getPathFriendlyURLPrivateUser();
543     }
544 
545     public static String getPathFriendlyURLPublic() {
546         return getPortal().getPathFriendlyURLPublic();
547     }
548 
549     public static String getPathImage() {
550         return getPortal().getPathImage();
551     }
552 
553     public static String getPathMain() {
554         return getPortal().getPathMain();
555     }
556 
557     public static long getPlidFromFriendlyURL(
558         long companyId, String friendlyURL) {
559 
560         return getPortal().getPlidFromFriendlyURL(companyId, friendlyURL);
561     }
562 
563     public static long getPlidFromPortletId(
564         long groupId, boolean privateLayout, String portletId) {
565 
566         return getPortal().getPlidFromPortletId(
567             groupId, privateLayout, portletId);
568     }
569 
570     public static long getPlidFromPortletId(long groupId, String portletId) {
571         return getPortal().getPlidFromPortletId(groupId, portletId);
572     }
573 
574     public static Portal getPortal() {
575         return _portal;
576     }
577 
578     public static String getPortalLibDir() {
579         return getPortal().getPortalLibDir();
580     }
581 
582     public static int getPortalPort() {
583         return getPortal().getPortalPort();
584     }
585 
586     public static Properties getPortalProperties() {
587         return getPortal().getPortalProperties();
588     }
589 
590     public static String getPortalURL(HttpServletRequest request) {
591         return getPortal().getPortalURL(request);
592     }
593 
594     public static String getPortalURL(
595         HttpServletRequest request, boolean secure) {
596 
597         return getPortal().getPortalURL(request, secure);
598     }
599 
600     public static String getPortalURL(PortletRequest portletRequest) {
601         return getPortal().getPortalURL(portletRequest);
602     }
603 
604     public static String getPortalURL(
605         PortletRequest portletRequest, boolean secure) {
606 
607         return getPortal().getPortalURL(portletRequest, secure);
608     }
609 
610     public static String getPortalURL(
611         String serverName, int serverPort, boolean secure) {
612 
613         return getPortal().getPortalURL(serverName, serverPort, secure);
614     }
615 
616     public static String getPortalURL(ThemeDisplay themeDisplay) {
617         return getPortal().getPortalURL(themeDisplay);
618     }
619 
620     public static String getPortalWebDir() {
621         return getPortal().getPortalWebDir();
622     }
623 
624     public static List<KeyValuePair> getPortletBreadcrumbList(
625         HttpServletRequest request) {
626 
627         return getPortal().getPortletBreadcrumbList(request);
628     }
629 
630     public static String getPortletDescription(
631         Portlet portlet, ServletContext servletContext, Locale locale) {
632 
633         return getPortal().getPortletDescription(
634             portlet, servletContext, locale);
635     }
636 
637     public static String getPortletDescription(Portlet portlet, User user) {
638         return getPortal().getPortletDescription(portlet, user);
639     }
640 
641     public static String getPortletDescription(
642         String portletId, Locale locale) {
643 
644         return getPortal().getPortletDescription(portletId, locale);
645     }
646 
647     public static String getPortletDescription(
648         String portletId, String languageId) {
649 
650         return getPortal().getPortletDescription(portletId, languageId);
651     }
652 
653     public static String getPortletDescription(String portletId, User user) {
654         return getPortal().getPortletDescription(portletId, user);
655     }
656 
657     public static Object[] getPortletFriendlyURLMapper(
658             long groupId, boolean privateLayout, String url)
659         throws PortalException, SystemException {
660 
661         return getPortal().getPortletFriendlyURLMapper(
662             groupId, privateLayout, url);
663     }
664 
665     public static Object[] getPortletFriendlyURLMapper(
666             long groupId, boolean privateLayout, String url,
667             Map<String, String[]> params)
668         throws PortalException, SystemException {
669 
670         return getPortal().getPortletFriendlyURLMapper(
671             groupId, privateLayout, url, params);
672     }
673 
674     /**
675      * @deprecated Use <code>getScopeGroupId</code>.
676      */
677     public static long getPortletGroupId(ActionRequest actionRequest) {
678         return getPortal().getPortletGroupId(actionRequest);
679     }
680 
681     /**
682      * @deprecated Use <code>getScopeGroupId</code>.
683      */
684     public static long getPortletGroupId(HttpServletRequest request) {
685         return getPortal().getPortletGroupId(request);
686     }
687 
688     /**
689      * @deprecated Use <code>getScopeGroupId</code>.
690      */
691     public static long getPortletGroupId(Layout layout) {
692         return getPortal().getPortletGroupId(layout);
693     }
694 
695     /**
696      * @deprecated Use <code>getScopeGroupId</code>.
697      */
698     public static long getPortletGroupId(long plid) {
699         return getPortal().getPortletGroupId(plid);
700     }
701 
702     /**
703      * @deprecated Use <code>getScopeGroupId</code>.
704      */
705     public static long getPortletGroupId(RenderRequest renderRequest) {
706         return getPortal().getPortletGroupId(renderRequest);
707     }
708 
709     public static String getPortletId(HttpServletRequest request) {
710         return getPortal().getPortletId(request);
711     }
712 
713     public static String getPortletId(PortletRequest portletRequest) {
714         return getPortal().getPortletId(portletRequest);
715     }
716 
717     public static String getPortletNamespace(String portletId) {
718         return getPortal().getPortletNamespace(portletId);
719     }
720 
721     public static String getPortletTitle(Portlet portlet, Locale locale) {
722         return getPortal().getPortletTitle(portlet, locale);
723     }
724 
725     public static String getPortletTitle(
726         Portlet portlet, ServletContext servletContext, Locale locale) {
727 
728         return getPortal().getPortletTitle(portlet, servletContext, locale);
729     }
730 
731     public static String getPortletTitle(Portlet portlet, String languageId) {
732         return getPortal().getPortletTitle(portlet, languageId);
733     }
734 
735     public static String getPortletTitle(Portlet portlet, User user) {
736         return getPortal().getPortletTitle(portlet, user);
737     }
738 
739     public static String getPortletTitle(String portletId, Locale locale) {
740         return getPortal().getPortletTitle(portletId, locale);
741     }
742 
743     public static String getPortletTitle(String portletId, String languageId) {
744         return getPortal().getPortletTitle(portletId, languageId);
745     }
746 
747     public static String getPortletTitle(String portletId, User user) {
748         return getPortal().getPortletTitle(portletId, user);
749     }
750 
751     public static String getPortletXmlFileName() throws SystemException {
752         return getPortal().getPortletXmlFileName();
753     }
754 
755     public static PortletPreferences getPreferences(
756         HttpServletRequest request) {
757 
758         return getPortal().getPreferences(request);
759     }
760 
761     public static PreferencesValidator getPreferencesValidator(
762         Portlet portlet) {
763 
764         return getPortal().getPreferencesValidator(portlet);
765     }
766 
767     public static long getScopeGroupId(HttpServletRequest request) {
768         return getPortal().getScopeGroupId(request);
769     }
770 
771     public static long getScopeGroupId(
772         HttpServletRequest request, String portletId) {
773 
774         return getPortal().getScopeGroupId(request, portletId);
775     }
776 
777     public static long getScopeGroupId(Layout layout) {
778         return getPortal().getScopeGroupId(layout);
779     }
780 
781     public static long getScopeGroupId(Layout layout, String portletId) {
782         return getPortal().getScopeGroupId(layout, portletId);
783     }
784 
785     public static long getScopeGroupId(long plid) {
786         return getPortal().getScopeGroupId(plid);
787     }
788 
789     public static long getScopeGroupId(PortletRequest portletRequest) {
790         return getPortal().getScopeGroupId(portletRequest);
791     }
792 
793     public static User getSelectedUser(HttpServletRequest request)
794         throws PortalException, SystemException {
795 
796         return getPortal().getSelectedUser(request);
797     }
798 
799     public static User getSelectedUser(
800             HttpServletRequest request, boolean checkPermission)
801         throws PortalException, SystemException {
802 
803         return getPortal().getSelectedUser(request, checkPermission);
804     }
805 
806     public static User getSelectedUser(PortletRequest portletRequest)
807         throws PortalException, SystemException {
808 
809         return getPortal().getSelectedUser(portletRequest);
810     }
811 
812     public static User getSelectedUser(
813             PortletRequest portletRequest, boolean checkPermission)
814         throws PortalException, SystemException {
815 
816         return getPortal().getSelectedUser(portletRequest, checkPermission);
817     }
818 
819     public static String getStaticResourceURL(
820         HttpServletRequest request, String uri) {
821 
822         return getPortal().getStaticResourceURL(request, uri);
823     }
824 
825     public static String getStaticResourceURL(
826         HttpServletRequest request, String uri, long timestamp) {
827 
828         return getPortal().getStaticResourceURL(request, uri, timestamp);
829     }
830 
831     public static String getStaticResourceURL(
832         HttpServletRequest request, String uri, String queryString) {
833 
834         return getPortal().getStaticResourceURL(request, uri, queryString);
835     }
836 
837     public static String getStaticResourceURL(
838         HttpServletRequest request, String uri, String queryString,
839         long timestamp) {
840 
841         return getPortal().getStaticResourceURL(
842             request, uri, queryString, timestamp);
843     }
844 
845     public static String getStrutsAction(HttpServletRequest request) {
846         return getPortal().getStrutsAction(request);
847     }
848 
849     public static String[] getSystemCommunityRoles() {
850         return getPortal().getSystemCommunityRoles();
851     }
852 
853     public static String[] getSystemGroups() {
854         return getPortal().getSystemGroups();
855     }
856 
857     public static String[] getSystemOrganizationRoles() {
858         return getPortal().getSystemOrganizationRoles();
859     }
860 
861     public static String[] getSystemRoles() {
862         return getPortal().getSystemRoles();
863     }
864 
865     public static UploadServletRequest getUploadServletRequest(
866         HttpServletRequest request) {
867 
868         return getPortal().getUploadServletRequest(request);
869     }
870 
871     public static UploadPortletRequest getUploadPortletRequest(
872         PortletRequest portletRequest) {
873 
874         return getPortal().getUploadPortletRequest(portletRequest);
875     }
876 
877     public static Date getUptime() {
878         return getPortal().getUptime();
879     }
880 
881     public static String getURLWithSessionId(String url, String sessionId) {
882         return getPortal().getURLWithSessionId(url, sessionId);
883     }
884 
885     public static User getUser(HttpServletRequest request)
886         throws PortalException, SystemException {
887 
888         return getPortal().getUser(request);
889     }
890 
891     public static User getUser(PortletRequest portletRequest)
892         throws PortalException, SystemException {
893 
894         return getPortal().getUser(portletRequest);
895     }
896 
897     public static long getUserId(HttpServletRequest request) {
898         return getPortal().getUserId(request);
899     }
900 
901     public static long getUserId(PortletRequest portletRequest) {
902         return getPortal().getUserId(portletRequest);
903     }
904 
905     public static String getUserName(long userId, String defaultUserName) {
906         return getPortal().getUserName(userId, defaultUserName);
907     }
908 
909     public static String getUserName(
910         long userId, String defaultUserName, HttpServletRequest request) {
911 
912         return getPortal().getUserName(userId, defaultUserName, request);
913     }
914 
915     public static String getUserName(
916         long userId, String defaultUserName, String userAttribute) {
917 
918         return getPortal().getUserName(userId, defaultUserName, userAttribute);
919     }
920 
921     public static String getUserName(
922         long userId, String defaultUserName, String userAttribute,
923         HttpServletRequest request) {
924 
925         return getPortal().getUserName(
926             userId, defaultUserName, userAttribute, request);
927     }
928 
929     public static String getUserPassword(HttpServletRequest request) {
930         return getPortal().getUserPassword(request);
931     }
932 
933     public static String getUserPassword(HttpSession session) {
934         return getPortal().getUserPassword(session);
935     }
936 
937     public static String getUserPassword(PortletRequest portletRequest) {
938         return getPortal().getUserPassword(portletRequest);
939     }
940 
941     public static String getUserValue(
942             long userId, String param, String defaultValue)
943         throws SystemException {
944 
945         return getPortal().getUserValue(userId, param, defaultValue);
946     }
947 
948     public static String getWidgetURL(
949         Portlet portlet, ThemeDisplay themeDisplay) {
950 
951         return getPortal().getWidgetURL(portlet, themeDisplay);
952     }
953 
954     public static boolean isLayoutFirstPageable(String type) {
955         return getPortal().isLayoutFirstPageable(type);
956     }
957 
958     public static boolean isLayoutFriendliable(Layout layout) {
959         return getPortal().isLayoutFriendliable(layout);
960     }
961 
962     public static boolean isLayoutParentable(Layout layout) {
963         return getPortal().isLayoutParentable(layout);
964     }
965 
966     public static boolean isLayoutParentable(String type) {
967         return getPortal().isLayoutParentable(type);
968     }
969 
970     public static boolean isLayoutSitemapable(Layout layout) {
971         return getPortal().isLayoutSitemapable(layout);
972     }
973 
974     public static boolean isMethodGet(PortletRequest portletRequest) {
975         return getPortal().isMethodGet(portletRequest);
976     }
977 
978     public static boolean isMethodPost(PortletRequest portletRequest) {
979         return getPortal().isMethodPost(portletRequest);
980     }
981 
982     public static boolean isReservedParameter(String name) {
983         return getPortal().isReservedParameter(name);
984     }
985 
986     public static boolean isSystemGroup(String groupName) {
987         return getPortal().isSystemGroup(groupName);
988     }
989 
990     public static boolean isSystemRole(String roleName) {
991         return getPortal().isSystemRole(roleName);
992     }
993 
994     public static boolean isUpdateAvailable() throws SystemException {
995         return getPortal().isUpdateAvailable();
996     }
997 
998     public static void renderPage(
999             StringBuilder sb, ServletContext servletContext,
1000            HttpServletRequest request, HttpServletResponse response,
1001            String path)
1002        throws IOException, ServletException {
1003
1004        getPortal().renderPage(sb, servletContext, request, response, path);
1005    }
1006
1007    public static void renderPortlet(
1008            StringBuilder sb, ServletContext servletContext,
1009            HttpServletRequest request, HttpServletResponse response,
1010            Portlet portlet, String queryString)
1011        throws IOException, ServletException {
1012
1013        getPortal().renderPortlet(
1014            sb, servletContext, request, response, portlet, queryString);
1015    }
1016
1017    public static void renderPortlet(
1018            StringBuilder sb, ServletContext servletContext,
1019            HttpServletRequest request, HttpServletResponse response,
1020            Portlet portlet, String queryString, String columnId,
1021            Integer columnPos, Integer columnCount)
1022        throws IOException, ServletException {
1023
1024        getPortal().renderPortlet(
1025            sb, servletContext, request, response, portlet, queryString,
1026            columnId, columnPos, columnCount);
1027    }
1028
1029    public static void renderPortlet(
1030            StringBuilder sb, ServletContext servletContext,
1031            HttpServletRequest request, HttpServletResponse response,
1032            Portlet portlet, String queryString, String columnId,
1033            Integer columnPos, Integer columnCount, String path)
1034        throws IOException, ServletException {
1035
1036        getPortal().renderPortlet(
1037            sb, servletContext, request, response, portlet, queryString,
1038            columnId, columnPos, columnCount, path);
1039    }
1040
1041    /**
1042     * @deprecated {@link DB#runSQL(String)}
1043     */
1044    public static void runSQL(String sql) throws IOException, SQLException {
1045        DBFactoryUtil.getDB().runSQL(sql);
1046    }
1047
1048    public static void sendError(
1049            Exception e, ActionRequest actionRequest,
1050            ActionResponse actionResponse)
1051        throws IOException {
1052
1053        getPortal().sendError(e, actionRequest, actionResponse);
1054    }
1055
1056    public static void sendError(
1057            Exception e, HttpServletRequest request,
1058            HttpServletResponse response)
1059        throws IOException, ServletException {
1060
1061        getPortal().sendError(e, request, response);
1062    }
1063
1064    public static void sendError(
1065            int status, Exception e, ActionRequest actionRequest,
1066            ActionResponse actionResponse)
1067        throws IOException {
1068
1069        getPortal().sendError(status, e, actionRequest, actionResponse);
1070    }
1071
1072    public static void sendError(
1073            int status, Exception e, HttpServletRequest request,
1074            HttpServletResponse response)
1075        throws IOException, ServletException {
1076
1077        getPortal().sendError(status, e, request, response);
1078    }
1079
1080    /**
1081     * Sets the description for a page. This overrides the existing page
1082     * description.
1083     */
1084    public static void setPageDescription(
1085        String description, HttpServletRequest request) {
1086
1087        getPortal().setPageDescription(description, request);
1088    }
1089
1090    /**
1091     * Sets the keywords for a page. This overrides the existing page keywords.
1092     */
1093    public static void setPageKeywords(
1094        String keywords, HttpServletRequest request) {
1095
1096        getPortal().setPageKeywords(keywords, request);
1097    }
1098
1099    /**
1100     * Sets the subtitle for a page. This overrides the existing page subtitle.
1101     */
1102    public static void setPageSubtitle(
1103        String subtitle, HttpServletRequest request) {
1104
1105        getPortal().setPageSubtitle(subtitle, request);
1106    }
1107
1108    /**
1109     * Sets the whole title for a page. This overrides the existing page whole
1110     * title.
1111     */
1112    public static void setPageTitle(
1113        String title, HttpServletRequest request) {
1114
1115        getPortal().setPageTitle(title, request);
1116    }
1117
1118    /**
1119     * Sets the port obtained on the first request to the portal.
1120     */
1121    public static void setPortalPort(HttpServletRequest request) {
1122        getPortal().setPortalPort(request);
1123    }
1124
1125    public static void storePreferences(PortletPreferences preferences)
1126        throws IOException, ValidatorException {
1127
1128        getPortal().storePreferences(preferences);
1129    }
1130
1131    public static String transformCustomSQL(String sql) {
1132        return getPortal().transformCustomSQL(sql);
1133    }
1134
1135    public static PortletMode updatePortletMode(
1136        String portletId, User user, Layout layout, PortletMode portletMode,
1137        HttpServletRequest request) {
1138
1139        return getPortal().updatePortletMode(
1140            portletId, user, layout, portletMode, request);
1141    }
1142
1143    public static WindowState updateWindowState(
1144        String portletId, User user, Layout layout, WindowState windowState,
1145        HttpServletRequest request) {
1146
1147        return getPortal().updateWindowState(
1148            portletId, user, layout, windowState, request);
1149    }
1150
1151    public void setPortal(Portal portal) {
1152        _portal = portal;
1153    }
1154
1155    private static Portal _portal;
1156
1157}