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