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