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