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