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