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