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