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