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