1   /**
2    * Copyright (c) 2000-2008 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.Company;
30  import com.liferay.portal.model.Layout;
31  import com.liferay.portal.model.LayoutSet;
32  import com.liferay.portal.model.Portlet;
33  import com.liferay.portal.model.User;
34  import com.liferay.portal.theme.ThemeDisplay;
35  
36  import java.io.IOException;
37  
38  import java.rmi.RemoteException;
39  
40  import java.util.Date;
41  import java.util.Locale;
42  import java.util.Map;
43  import java.util.Properties;
44  import java.util.TimeZone;
45  
46  import javax.portlet.ActionRequest;
47  import javax.portlet.ActionResponse;
48  import javax.portlet.PortletMode;
49  import javax.portlet.PortletPreferences;
50  import javax.portlet.PortletRequest;
51  import javax.portlet.PortletResponse;
52  import javax.portlet.PreferencesValidator;
53  import javax.portlet.RenderRequest;
54  import javax.portlet.ValidatorException;
55  import javax.portlet.WindowState;
56  
57  import javax.servlet.ServletContext;
58  import javax.servlet.ServletException;
59  import javax.servlet.http.HttpServletRequest;
60  import javax.servlet.http.HttpServletResponse;
61  import javax.servlet.http.HttpSession;
62  
63  /**
64   * <a href="PortalUtil.java.html"><b><i>View Source</i></b></a>
65   *
66   * @author Brian Wing Shun Chan
67   *
68   */
69  public class PortalUtil {
70  
71      public static void clearRequestParameters(RenderRequest renderRequest) {
72          getPortal().clearRequestParameters(renderRequest);
73      }
74  
75      public static void copyRequestParameters(
76          ActionRequest actionRequest, ActionResponse actionResponse) {
77  
78          getPortal().copyRequestParameters(actionRequest, actionResponse);
79      }
80  
81      public static String getCDNHost() {
82          return getPortal().getCDNHost();
83      }
84  
85      public static String getClassName(long classNameId) {
86          return getPortal().getClassName(classNameId);
87      }
88  
89      public static long getClassNameId(Class<?> classObj) {
90          return getPortal().getClassNameId(classObj);
91      }
92  
93      public static long getClassNameId(String value) {
94          return getPortal().getClassNameId(value);
95      }
96  
97      public static String getClassNamePortletId(String className) {
98          return getPortal().getClassNamePortletId(className);
99      }
100 
101     public static String getCommunityLoginURL(ThemeDisplay themeDisplay)
102         throws PortalException, SystemException {
103 
104         return getPortal().getCommunityLoginURL(themeDisplay);
105     }
106 
107     public static Company getCompany(HttpServletRequest request)
108         throws PortalException, SystemException {
109 
110         return getPortal().getCompany(request);
111     }
112 
113     public static Company getCompany(PortletRequest portletRequest)
114         throws PortalException, SystemException {
115 
116         return getPortal().getCompany(portletRequest);
117     }
118 
119     public static long getCompanyId(HttpServletRequest request) {
120         return getPortal().getCompanyId(request);
121     }
122 
123     public static long getCompanyId(PortletRequest portletRequest) {
124         return getPortal().getCompanyId(portletRequest);
125     }
126 
127     public static long getCompanyIdByWebId(ServletContext servletContext) {
128         return getPortal().getCompanyIdByWebId(servletContext);
129     }
130 
131     public static long getCompanyIdByWebId(String webId) {
132         return getPortal().getCompanyIdByWebId(webId);
133     }
134 
135     public static long[] getCompanyIds() {
136         return getPortal().getCompanyIds();
137     }
138 
139     public static String getComputerAddress() {
140         return getPortal().getComputerAddress();
141     }
142 
143     public static String getComputerName() {
144         return getPortal().getComputerName();
145     }
146 
147     public static String getCurrentURL(HttpServletRequest request) {
148         return getPortal().getCurrentURL(request);
149     }
150 
151     public static String getCurrentURL(PortletRequest portletRequest) {
152         return getPortal().getCurrentURL(portletRequest);
153     }
154 
155     public static String getCustomSQLFunctionIsNotNull() {
156         return getPortal().getCustomSQLFunctionIsNotNull();
157     }
158 
159     public static String getCustomSQLFunctionIsNull() {
160         return getPortal().getCustomSQLFunctionIsNull();
161     }
162 
163     public static Date getDate(int month, int day, int year, PortalException pe)
164         throws PortalException {
165 
166         return getPortal().getDate(month, day, year, pe);
167     }
168 
169     public static Date getDate(
170             int month, int day, int year, TimeZone timeZone, PortalException pe)
171         throws PortalException {
172 
173         return getPortal().getDate(month, day, year, timeZone, pe);
174     }
175 
176     public static Date getDate(
177             int month, int day, int year, int hour, int min, PortalException pe)
178         throws PortalException {
179 
180         return getPortal().getDate(month, day, year, hour, min, pe);
181     }
182 
183     public static Date getDate(
184             int month, int day, int year, int hour, int min, TimeZone timeZone,
185             PortalException pe)
186         throws PortalException {
187 
188         return getPortal().getDate(month, day, year, hour, min, timeZone, pe);
189     }
190 
191     public static long getDefaultCompanyId() {
192         return getPortal().getDefaultCompanyId();
193     }
194 
195     public static String getHost(HttpServletRequest request) {
196         return getPortal().getHost(request);
197     }
198 
199     public static String getHost(PortletRequest portletRequest) {
200         return getPortal().getHost(portletRequest);
201     }
202 
203     public static HttpServletRequest getHttpServletRequest(
204         PortletRequest portletRequest) {
205 
206         return getPortal().getHttpServletRequest(portletRequest);
207     }
208 
209     public static HttpServletResponse getHttpServletResponse(
210         PortletResponse portletResponse) {
211 
212         return getPortal().getHttpServletResponse(portletResponse);
213     }
214 
215     public static String getLayoutEditPage(Layout layout) {
216         return getPortal().getLayoutEditPage(layout);
217     }
218 
219     public static String getLayoutViewPage(Layout layout) {
220         return getPortal().getLayoutViewPage(layout);
221     }
222 
223     public static String getLayoutURL(ThemeDisplay themeDisplay) {
224         return getPortal().getLayoutURL(themeDisplay);
225     }
226 
227     public static String getLayoutURL(
228         Layout layout, ThemeDisplay themeDisplay) {
229 
230         return getPortal().getLayoutURL(layout, themeDisplay);
231     }
232 
233     public static String getLayoutURL(
234         Layout layout, ThemeDisplay themeDisplay, boolean doAsUser) {
235 
236         return getPortal().getLayoutURL(layout, themeDisplay, doAsUser);
237     }
238 
239     public static String getLayoutActualURL(Layout layout) {
240         return getPortal().getLayoutActualURL(layout);
241     }
242 
243     public static String getLayoutActualURL(Layout layout, String mainPath) {
244         return getPortal().getLayoutActualURL(layout, mainPath);
245     }
246 
247     public static String getLayoutActualURL(
248             long groupId, boolean privateLayout, String mainPath,
249             String friendlyURL)
250         throws PortalException, SystemException {
251 
252         return getPortal().getLayoutActualURL(
253             groupId, privateLayout, mainPath, friendlyURL);
254     }
255 
256     public static String getLayoutActualURL(
257             long groupId, boolean privateLayout, String mainPath,
258             String friendlyURL, Map<String, String[]> params)
259         throws PortalException, SystemException {
260 
261         return getPortal().getLayoutActualURL(
262             groupId, privateLayout, mainPath, friendlyURL, params);
263     }
264 
265     public static String getLayoutFriendlyURL(
266         Layout layout, ThemeDisplay themeDisplay) {
267 
268         return getPortal().getLayoutFriendlyURL(layout, themeDisplay);
269     }
270 
271     public static String getLayoutSetFriendlyURL(
272             LayoutSet layoutSet, ThemeDisplay themeDisplay)
273         throws PortalException, SystemException {
274 
275         return getPortal().getLayoutSetFriendlyURL(layoutSet, themeDisplay);
276     }
277 
278     public static String getLayoutTarget(Layout layout) {
279         return getPortal().getLayoutTarget(layout);
280     }
281 
282     public static String getJsSafePortletId(String portletId) {
283         return getPortal().getJsSafePortletId(portletId);
284     }
285 
286     public static Locale getLocale(HttpServletRequest request) {
287         return getPortal().getLocale(request);
288     }
289 
290     public static Locale getLocale(RenderRequest renderRequest) {
291         return getPortal().getLocale(renderRequest);
292     }
293 
294     public static HttpServletRequest getOriginalServletRequest(
295         HttpServletRequest request) {
296 
297         return getPortal().getOriginalServletRequest(request);
298     }
299 
300     public static String getPathContext() {
301         return getPortal().getPathContext();
302     }
303 
304     public static String getPathFriendlyURLPrivateGroup() {
305         return getPortal().getPathFriendlyURLPrivateGroup();
306     }
307 
308     public static String getPathFriendlyURLPrivateUser() {
309         return getPortal().getPathFriendlyURLPrivateUser();
310     }
311 
312     public static String getPathFriendlyURLPublic() {
313         return getPortal().getPathFriendlyURLPublic();
314     }
315 
316     public static String getPathImage() {
317         return getPortal().getPathImage();
318     }
319 
320     public static String getPathMain() {
321         return getPortal().getPathMain();
322     }
323 
324     public static long getPlidFromFriendlyURL(
325         long companyId, String friendlyURL) {
326 
327         return getPortal().getPlidFromFriendlyURL(companyId, friendlyURL);
328     }
329 
330     public static long getPlidFromPortletId(
331         long groupId, boolean privateLayout, String portletId) {
332 
333         return getPortal().getPlidFromPortletId(
334             groupId, privateLayout, portletId);
335     }
336 
337     public static Portal getPortal() {
338         return _portal;
339     }
340 
341     public static String getPortalLibDir() {
342         return getPortal().getPortalLibDir();
343     }
344 
345     public static int getPortalPort() {
346         return getPortal().getPortalPort();
347     }
348 
349     public static Properties getPortalProperties() {
350         return getPortal().getPortalProperties();
351     }
352 
353     public static String getPortalURL(ThemeDisplay themeDisplay) {
354         return getPortal().getPortalURL(themeDisplay);
355     }
356 
357     public static String getPortalURL(HttpServletRequest request) {
358         return getPortal().getPortalURL(request);
359     }
360 
361     public static String getPortalURL(
362         HttpServletRequest request, boolean secure) {
363 
364         return getPortal().getPortalURL(request, secure);
365     }
366 
367     public static String getPortalURL(PortletRequest portletRequest) {
368         return getPortal().getPortalURL(portletRequest);
369     }
370 
371     public static String getPortalURL(
372         PortletRequest portletRequest, boolean secure) {
373 
374         return getPortal().getPortalURL(portletRequest, secure);
375     }
376 
377     public static String getPortalURL(
378         String serverName, int serverPort, boolean secure) {
379 
380         return getPortal().getPortalURL(serverName, serverPort, secure);
381     }
382 
383     public static String getPortalWebDir() {
384         return getPortal().getPortalWebDir();
385     }
386 
387     public static Object[] getPortletFriendlyURLMapper(
388             long groupId, boolean privateLayout, String url)
389         throws PortalException, SystemException {
390 
391         return getPortal().getPortletFriendlyURLMapper(
392             groupId, privateLayout, url);
393     }
394 
395     public static Object[] getPortletFriendlyURLMapper(
396             long groupId, boolean privateLayout, String url,
397             Map<String, String[]> params)
398         throws PortalException, SystemException {
399 
400         return getPortal().getPortletFriendlyURLMapper(
401             groupId, privateLayout, url, params);
402     }
403 
404     /**
405      * @deprecated Use <code>getScopeGroupId</code>.
406      */
407     public static long getPortletGroupId(long plid) {
408         return getPortal().getPortletGroupId(plid);
409     }
410 
411     /**
412      * @deprecated Use <code>getScopeGroupId</code>.
413      */
414     public static long getPortletGroupId(Layout layout) {
415         return getPortal().getPortletGroupId(layout);
416     }
417 
418     /**
419      * @deprecated Use <code>getScopeGroupId</code>.
420      */
421     public static long getPortletGroupId(HttpServletRequest request) {
422         return getPortal().getPortletGroupId(request);
423     }
424 
425     /**
426      * @deprecated Use <code>getScopeGroupId</code>.
427      */
428     public static long getPortletGroupId(ActionRequest actionRequest) {
429         return getPortal().getPortletGroupId(actionRequest);
430     }
431 
432     /**
433      * @deprecated Use <code>getScopeGroupId</code>.
434      */
435     public static long getPortletGroupId(RenderRequest renderRequest) {
436         return getPortal().getPortletGroupId(renderRequest);
437     }
438 
439     public static String getPortletId(HttpServletRequest request) {
440         return getPortal().getPortletId(request);
441     }
442 
443     public static String getPortletId(PortletRequest portletRequest) {
444         return getPortal().getPortletId(portletRequest);
445     }
446 
447     public static String getPortletNamespace(String portletId) {
448         return getPortal().getPortletNamespace(portletId);
449     }
450 
451     public static String getPortletTitle(
452         String portletId, long companyId, String languageId) {
453 
454         return getPortal().getPortletTitle(portletId, companyId, languageId);
455     }
456 
457     public static String getPortletTitle(
458         String portletId, long companyId, Locale locale) {
459 
460         return getPortal().getPortletTitle(portletId, companyId, locale);
461     }
462 
463     public static String getPortletTitle(String portletId, User user) {
464         return getPortal().getPortletTitle(portletId, user);
465     }
466 
467     public static String getPortletTitle(
468         Portlet portlet, long companyId, String languageId) {
469 
470         return getPortletTitle(portlet, companyId, languageId);
471     }
472 
473     public static String getPortletTitle(
474         Portlet portlet, long companyId, Locale locale) {
475 
476         return getPortal().getPortletTitle(portlet, companyId, locale);
477     }
478 
479     public static String getPortletTitle(Portlet portlet, User user) {
480         return getPortal().getPortletTitle(portlet, user);
481     }
482 
483     public static String getPortletTitle(
484         Portlet portlet, ServletContext servletContext, Locale locale) {
485 
486         return getPortal().getPortletTitle(portlet, servletContext, locale);
487     }
488 
489     public static String getPortletXmlFileName() throws SystemException {
490         return getPortal().getPortletXmlFileName();
491     }
492 
493     public static PortletPreferences getPreferences(
494         HttpServletRequest request) {
495 
496         return getPortal().getPreferences(request);
497     }
498 
499     public static PreferencesValidator getPreferencesValidator(
500         Portlet portlet) {
501 
502         return getPortal().getPreferencesValidator(portlet);
503     }
504 
505     public static long getScopeGroupId(long plid) {
506         return getPortal().getScopeGroupId(plid);
507     }
508 
509     public static long getScopeGroupId(Layout layout) {
510         return getPortal().getScopeGroupId(layout);
511     }
512 
513     public static long getScopeGroupId(HttpServletRequest request) {
514         return getPortal().getScopeGroupId(request);
515     }
516 
517     public static long getScopeGroupId(PortletRequest portletRequest) {
518         return getPortal().getScopeGroupId(portletRequest);
519     }
520 
521     public static User getSelectedUser(HttpServletRequest request)
522         throws PortalException, RemoteException, SystemException {
523 
524         return getPortal().getSelectedUser(request);
525     }
526 
527     public static User getSelectedUser(
528             HttpServletRequest request, boolean checkPermission)
529         throws PortalException, RemoteException, SystemException {
530 
531         return getPortal().getSelectedUser(request, checkPermission);
532     }
533 
534     public static User getSelectedUser(PortletRequest portletRequest)
535         throws PortalException, RemoteException, SystemException {
536 
537         return getPortal().getSelectedUser(portletRequest);
538     }
539 
540     public static User getSelectedUser(
541             PortletRequest portletRequest, boolean checkPermission)
542         throws PortalException, RemoteException, SystemException {
543 
544         return getPortal().getSelectedUser(portletRequest, checkPermission);
545     }
546 
547     public static String getStrutsAction(HttpServletRequest request) {
548         return getPortal().getStrutsAction(request);
549     }
550 
551     public static String[] getSystemCommunityRoles() {
552         return getPortal().getSystemCommunityRoles();
553     }
554 
555     public static String[] getSystemGroups() {
556         return getPortal().getSystemGroups();
557     }
558 
559     public static String[] getSystemOrganizationRoles() {
560         return getPortal().getSystemOrganizationRoles();
561     }
562 
563     public static String[] getSystemRoles() {
564         return getPortal().getSystemRoles();
565     }
566 
567     public static UploadPortletRequest getUploadPortletRequest(
568         ActionRequest actionRequest) {
569 
570         return getPortal().getUploadPortletRequest(actionRequest);
571     }
572 
573     public static UploadServletRequest getUploadServletRequest(
574         HttpServletRequest request) {
575 
576         return getPortal().getUploadServletRequest(request);
577     }
578 
579     public static Date getUptime() {
580         return getPortal().getUptime();
581     }
582 
583     public static String getURLWithSessionId(String url, String sessionId) {
584         return getPortal().getURLWithSessionId(url, sessionId);
585     }
586 
587     public static User getUser(HttpServletRequest request)
588         throws PortalException, SystemException {
589 
590         return getPortal().getUser(request);
591     }
592 
593     public static User getUser(PortletRequest portletRequest)
594         throws PortalException, SystemException {
595 
596         return getPortal().getUser(portletRequest);
597     }
598 
599     public static long getUserId(HttpServletRequest request) {
600         return getPortal().getUserId(request);
601     }
602 
603     public static long getUserId(PortletRequest portletRequest) {
604         return getPortal().getUserId(portletRequest);
605     }
606 
607     public static String getUserName(long userId, String defaultUserName) {
608         return getPortal().getUserName(userId, defaultUserName);
609     }
610 
611     public static String getUserName(
612         long userId, String defaultUserName, String userAttribute) {
613 
614         return getPortal().getUserName(userId, defaultUserName, userAttribute);
615     }
616 
617     public static String getUserName(
618         long userId, String defaultUserName, HttpServletRequest request) {
619 
620         return getPortal().getUserName(userId, defaultUserName, request);
621     }
622 
623     public static String getUserName(
624         long userId, String defaultUserName, String userAttribute,
625         HttpServletRequest request) {
626 
627         return getPortal().getUserName(
628             userId, defaultUserName, userAttribute, request);
629     }
630 
631     public static String getUserPassword(HttpSession session) {
632         return getPortal().getUserPassword(session);
633     }
634 
635     public static String getUserPassword(HttpServletRequest request) {
636         return getPortal().getUserPassword(request);
637     }
638 
639     public static String getUserPassword(PortletRequest portletRequest) {
640         return getPortal().getUserPassword(portletRequest);
641     }
642 
643     public static String getUserValue(
644             long userId, String param, String defaultValue)
645         throws SystemException {
646 
647         return getPortal().getUserValue(userId, param, defaultValue);
648     }
649 
650     public static String getWidgetURL(
651         Portlet portlet, ThemeDisplay themeDisplay) {
652 
653         return getPortal().getWidgetURL(portlet, themeDisplay);
654     }
655 
656     public static boolean isMethodGet(PortletRequest portletRequest) {
657         return getPortal().isMethodGet(portletRequest);
658     }
659 
660     public static boolean isMethodPost(PortletRequest portletRequest) {
661         return getPortal().isMethodPost(portletRequest);
662     }
663 
664     public static boolean isLayoutFriendliable(Layout layout) {
665         return getPortal().isLayoutFriendliable(layout);
666     }
667 
668     public static boolean isLayoutParentable(Layout layout) {
669         return getPortal().isLayoutParentable(layout);
670     }
671 
672     public static boolean isLayoutParentable(String type) {
673         return getPortal().isLayoutParentable(type);
674     }
675 
676     public static boolean isLayoutSitemapable(Layout layout) {
677         return getPortal().isLayoutSitemapable(layout);
678     }
679 
680     public static boolean isReservedParameter(String name) {
681         return getPortal().isReservedParameter(name);
682     }
683 
684     public static boolean isSystemGroup(String groupName) {
685         return getPortal().isSystemGroup(groupName);
686     }
687 
688     public static boolean isSystemRole(String roleName) {
689         return getPortal().isSystemRole(roleName);
690     }
691 
692     public static boolean isUpdateAvailable()
693         throws PortalException, SystemException {
694 
695         return getPortal().isUpdateAvailable();
696     }
697 
698     public static void renderPage(
699             StringBuilder sb, ServletContext servletContext,
700             HttpServletRequest request, HttpServletResponse response,
701             String path)
702         throws IOException, ServletException {
703 
704         getPortal().renderPage(sb, servletContext, request, response, path);
705     }
706 
707     public static void renderPortlet(
708             StringBuilder sb, ServletContext servletContext,
709             HttpServletRequest request, HttpServletResponse response,
710             Portlet portlet, String queryString)
711         throws IOException, ServletException {
712 
713         getPortal().renderPortlet(
714             sb, servletContext, request, response, portlet, queryString);
715     }
716 
717     public static void renderPortlet(
718             StringBuilder sb, ServletContext servletContext,
719             HttpServletRequest request, HttpServletResponse response,
720             Portlet portlet, String queryString, String columnId,
721             Integer columnPos, Integer columnCount)
722         throws IOException, ServletException {
723 
724         getPortal().renderPortlet(
725             sb, servletContext, request, response, portlet, queryString,
726             columnId, columnPos, columnCount);
727     }
728 
729     public static void renderPortlet(
730             StringBuilder sb, ServletContext servletContext,
731             HttpServletRequest request, HttpServletResponse response,
732             Portlet portlet, String queryString, String columnId,
733             Integer columnPos, Integer columnCount, String path)
734         throws IOException, ServletException {
735 
736         getPortal().renderPortlet(
737             sb, servletContext, request, response, portlet, queryString,
738             columnId, columnPos, columnCount, path);
739     }
740 
741     public static void sendError(
742             Exception e, HttpServletRequest request,
743             HttpServletResponse response)
744         throws IOException, ServletException {
745 
746         getPortal().sendError(e, request, response);
747     }
748 
749     public static void sendError(
750             int status, Exception e, HttpServletRequest request,
751             HttpServletResponse response)
752         throws IOException, ServletException {
753 
754         getPortal().sendError(status, e, request, response);
755     }
756 
757     public static void sendError(
758             Exception e, ActionRequest actionRequest,
759             ActionResponse actionResponse)
760         throws IOException {
761 
762         getPortal().sendError(e, actionRequest, actionResponse);
763     }
764 
765     public static void sendError(
766             int status, Exception e, ActionRequest actionRequest,
767             ActionResponse actionResponse)
768         throws IOException {
769 
770         getPortal().sendError(status, e, actionRequest, actionResponse);
771     }
772 
773     /**
774      * Sets the subtitle for a page. This is just a hint and can be overridden
775      * by subsequent calls. The last call to this method wins.
776      *
777      * @param       subtitle the subtitle for a page
778      * @param       req the HTTP servlet request
779      */
780     public static void setPageSubtitle(
781         String subtitle, HttpServletRequest request) {
782 
783         getPortal().setPageSubtitle(subtitle, request);
784     }
785 
786     /**
787      * Sets the whole title for a page. This is just a hint and can be
788      * overridden by subsequent calls. The last call to this method wins.
789      *
790      * @param       title the whole title for a page
791      * @param       req the HTTP servlet request
792      */
793     public static void setPageTitle(String title, HttpServletRequest request) {
794         getPortal().setPageTitle(title, request);
795     }
796 
797     /**
798      * Sets the port obtained on the first request to the portal.
799      *
800      * @param       req the HTTP servlet request
801      */
802     public static void setPortalPort(HttpServletRequest request) {
803         getPortal().setPortalPort(request);
804     }
805 
806     public static void storePreferences(PortletPreferences prefs)
807         throws IOException, ValidatorException {
808 
809         getPortal().storePreferences(prefs);
810     }
811 
812     public static String transformCustomSQL(String sql) {
813         return getPortal().transformCustomSQL(sql);
814     }
815 
816     public static PortletMode updatePortletMode(
817         String portletId, User user, Layout layout, PortletMode portletMode,
818         HttpServletRequest request) {
819 
820         return getPortal().updatePortletMode(
821             portletId, user, layout, portletMode, request);
822     }
823 
824     public static WindowState updateWindowState(
825         String portletId, User user, Layout layout, WindowState windowState,
826         HttpServletRequest request) {
827 
828         return getPortal().updateWindowState(
829             portletId, user, layout, windowState, request);
830     }
831 
832     public void setPortal(Portal portal) {
833         _portal = portal;
834     }
835 
836     private static Portal _portal;
837 
838 }