1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.util;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.kernel.dao.db.DB;
20  import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
21  import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
22  import com.liferay.portal.kernel.upload.UploadPortletRequest;
23  import com.liferay.portal.kernel.upload.UploadServletRequest;
24  import com.liferay.portal.model.BaseModel;
25  import com.liferay.portal.model.Company;
26  import com.liferay.portal.model.Layout;
27  import com.liferay.portal.model.LayoutSet;
28  import com.liferay.portal.model.Portlet;
29  import com.liferay.portal.model.Resource;
30  import com.liferay.portal.model.ResourcePermission;
31  import com.liferay.portal.model.User;
32  import com.liferay.portal.theme.ThemeDisplay;
33  import com.liferay.portlet.expando.model.ExpandoBridge;
34  
35  import java.io.IOException;
36  import java.io.Serializable;
37  
38  import java.sql.SQLException;
39  
40  import java.util.Date;
41  import java.util.List;
42  import java.util.Locale;
43  import java.util.Map;
44  import java.util.Properties;
45  import java.util.Set;
46  import java.util.TimeZone;
47  
48  import javax.portlet.ActionRequest;
49  import javax.portlet.ActionResponse;
50  import javax.portlet.PortletMode;
51  import javax.portlet.PortletPreferences;
52  import javax.portlet.PortletRequest;
53  import javax.portlet.PortletResponse;
54  import javax.portlet.PreferencesValidator;
55  import javax.portlet.RenderRequest;
56  import javax.portlet.RenderResponse;
57  import javax.portlet.ValidatorException;
58  import javax.portlet.WindowState;
59  
60  import javax.servlet.ServletContext;
61  import javax.servlet.ServletException;
62  import javax.servlet.http.HttpServletRequest;
63  import javax.servlet.http.HttpServletResponse;
64  import javax.servlet.http.HttpSession;
65  import javax.servlet.jsp.PageContext;
66  
67  /**
68   * <a href="PortalUtil.java.html"><b><i>View Source</i></b></a>
69   *
70   * @author Brian Wing Shun Chan
71   * @author Eduardo Lundgren
72   */
73  public class PortalUtil {
74  
75      /**
76       * Adds the description for a page. This appends to the existing page
77       * description.
78       */
79      public static void addPageDescription(
80          String description, HttpServletRequest request) {
81  
82          getPortal().addPageDescription(description, request);
83      }
84  
85      /**
86       * Adds the keywords for a page. This appends to the existing page keywords.
87       */
88      public static void addPageKeywords(
89          String keywords, HttpServletRequest request) {
90  
91          getPortal().addPageKeywords(keywords, request);
92      }
93  
94      /**
95       * Adds the subtitle for a page. This appends to the existing page subtitle.
96       */
97      public static void addPageSubtitle(
98          String subtitle, HttpServletRequest request) {
99  
100         getPortal().addPageSubtitle(subtitle, request);
101     }
102 
103     /**
104      * Adds the whole title for a page. This appends to the existing page whole
105      * title.
106      */
107     public static void addPageTitle(String title, HttpServletRequest request) {
108         getPortal().addPageTitle(title, request);
109     }
110 
111     public static void addPortalPortEventListener(
112         PortalPortEventListener portalPortEventListener) {
113 
114         getPortal().addPortalPortEventListener(portalPortEventListener);
115     }
116 
117     public static void addPortletDefaultResource(
118             HttpServletRequest request, Portlet portlet)
119         throws PortalException, SystemException {
120 
121         getPortal().addPortletDefaultResource(request, portlet);
122     }
123 
124     /**
125      * Adds reserved parameters such as doAsGroupId, doAsUserId,
126      * doAsUserLanguageId, and referrerPlid that should always be preserved as
127      * the user navigates through the portal. If doAsUser is false, then
128      * doAsUserId and doAsUserLanguageId will never be added.
129      */
130     public static String addPreservedParameters(
131         ThemeDisplay themeDisplay, Layout layout, String url,
132         boolean doAsUser) {
133 
134         return getPortal().addPreservedParameters(
135             themeDisplay, layout, url, doAsUser);
136     }
137 
138     /**
139      * Adds reserved parameters such as doAsGroupId, doAsUserId,
140      * doAsUserLanguageId, and referrerPlid that should always be preserved as
141      * the user navigates through the portal.
142      */
143     public static String addPreservedParameters(
144         ThemeDisplay themeDisplay, String url) {
145 
146         return getPortal().addPreservedParameters(themeDisplay, url);
147     }
148 
149     public static void clearRequestParameters(RenderRequest renderRequest) {
150         getPortal().clearRequestParameters(renderRequest);
151     }
152 
153     public static void copyRequestParameters(
154         ActionRequest actionRequest, ActionResponse actionResponse) {
155 
156         getPortal().copyRequestParameters(actionRequest, actionResponse);
157     }
158 
159     public static String escapeRedirect(String url) {
160         return getPortal().escapeRedirect(url);
161     }
162 
163     public static String generateRandomKey(
164         HttpServletRequest request, String input) {
165 
166         return getPortal().generateRandomKey(request, input);
167     }
168 
169     public static BaseModel<?> getBaseModel(Resource resource)
170         throws PortalException, SystemException {
171 
172         return getPortal().getBaseModel(resource);
173     }
174 
175     public static BaseModel<?> getBaseModel(
176             ResourcePermission resourcePermission)
177         throws PortalException, SystemException {
178 
179         return getPortal().getBaseModel(resourcePermission);
180     }
181 
182     public static BaseModel<?> getBaseModel(String modelName, String primKey)
183         throws PortalException, SystemException {
184 
185         return getPortal().getBaseModel(modelName, primKey);
186     }
187 
188     public static long getBasicAuthUserId(HttpServletRequest request)
189         throws PortalException, SystemException {
190 
191         return getPortal().getBasicAuthUserId(request);
192     }
193 
194     public static long getBasicAuthUserId(
195             HttpServletRequest request, long companyId)
196         throws PortalException, SystemException {
197 
198         return getPortal().getBasicAuthUserId(request, companyId);
199     }
200 
201     /**
202      * @deprecated {@link #getCDNHost(boolean)}
203      */
204     public static String getCDNHost() {
205         return getPortal().getCDNHost();
206     }
207 
208     public static String getCDNHost(boolean secure) {
209         return getPortal().getCDNHost(secure);
210     }
211 
212     public static String getCDNHostHttp() {
213         return getPortal().getCDNHostHttp();
214     }
215 
216     public static String getCDNHostHttps() {
217         return getPortal().getCDNHostHttps();
218     }
219 
220     public static String getClassName(long classNameId) {
221         return getPortal().getClassName(classNameId);
222     }
223 
224     public static long getClassNameId(Class<?> classObj) {
225         return getPortal().getClassNameId(classObj);
226     }
227 
228     public static long getClassNameId(String value) {
229         return getPortal().getClassNameId(value);
230     }
231 
232     public static String getClassNamePortletId(String className) {
233         return getPortal().getClassNamePortletId(className);
234     }
235 
236     public static String getCommunityLoginURL(ThemeDisplay themeDisplay)
237         throws PortalException, SystemException {
238 
239         return getPortal().getCommunityLoginURL(themeDisplay);
240     }
241 
242     public static String[] getCommunityPermissions(HttpServletRequest request) {
243         return getPortal().getCommunityPermissions(request);
244     }
245 
246     public static String[] getCommunityPermissions(
247         PortletRequest portletRequest) {
248 
249         return getPortal().getCommunityPermissions(portletRequest);
250     }
251 
252     public static Company getCompany(HttpServletRequest request)
253         throws PortalException, SystemException {
254 
255         return getPortal().getCompany(request);
256     }
257 
258     public static Company getCompany(PortletRequest portletRequest)
259         throws PortalException, SystemException {
260 
261         return getPortal().getCompany(portletRequest);
262     }
263 
264     public static long getCompanyId(HttpServletRequest request) {
265         return getPortal().getCompanyId(request);
266     }
267 
268     public static long getCompanyId(PortletRequest portletRequest) {
269         return getPortal().getCompanyId(portletRequest);
270     }
271 
272     public static long[] getCompanyIds() {
273         return getPortal().getCompanyIds();
274     }
275 
276     public static String getComputerAddress() {
277         return getPortal().getComputerAddress();
278     }
279 
280     public static String getComputerName() {
281         return getPortal().getComputerName();
282     }
283 
284     public static String getControlPanelCategory(
285             String portletId, ThemeDisplay themeDisplay)
286         throws SystemException {
287 
288         return getPortal().getControlPanelCategory(portletId, themeDisplay);
289     }
290 
291     public static String getControlPanelFullURL(
292             long scopeGroupId, String ppid, Map<String, String[]> params)
293         throws PortalException, SystemException {
294 
295         return getPortal().getControlPanelFullURL(scopeGroupId, ppid, params);
296     }
297 
298     public static List<Portlet> getControlPanelPortlets(
299             String category, ThemeDisplay themeDisplay)
300         throws SystemException {
301 
302         return getPortal().getControlPanelPortlets(
303             category, themeDisplay);
304     }
305 
306     public static String getCurrentCompleteURL(HttpServletRequest request) {
307         return getPortal().getCurrentCompleteURL(request);
308     }
309 
310     public static String getCurrentURL(HttpServletRequest request) {
311         return getPortal().getCurrentURL(request);
312     }
313 
314     public static String getCurrentURL(PortletRequest portletRequest) {
315         return getPortal().getCurrentURL(portletRequest);
316     }
317 
318     public static String getCustomSQLFunctionIsNotNull() {
319         return getPortal().getCustomSQLFunctionIsNotNull();
320     }
321 
322     public static String getCustomSQLFunctionIsNull() {
323         return getPortal().getCustomSQLFunctionIsNull();
324     }
325 
326     public static Date getDate(int month, int day, int year) {
327         return getPortal().getDate(month, day, year);
328     }
329 
330     public static Date getDate(
331             int month, int day, int year, int hour, int min, PortalException pe)
332         throws PortalException {
333 
334         return getPortal().getDate(month, day, year, hour, min, pe);
335     }
336 
337     public static Date getDate(
338             int month, int day, int year, int hour, int min, TimeZone timeZone,
339             PortalException pe)
340         throws PortalException {
341 
342         return getPortal().getDate(month, day, year, hour, min, timeZone, pe);
343     }
344 
345     public static Date getDate(int month, int day, int year, PortalException pe)
346         throws PortalException {
347 
348         return getPortal().getDate(month, day, year, pe);
349     }
350 
351     public static Date getDate(
352             int month, int day, int year, TimeZone timeZone, PortalException pe)
353         throws PortalException {
354 
355         return getPortal().getDate(month, day, year, timeZone, pe);
356     }
357 
358     /**
359      * @deprecated {@link DBFactoryUtil#getDB()}
360      */
361     public static DB getDB() {
362         return DBFactoryUtil.getDB();
363     }
364 
365     public static long getDefaultCompanyId() {
366         return getPortal().getDefaultCompanyId();
367     }
368 
369     public static Map<String, Serializable> getExpandoBridgeAttributes(
370             ExpandoBridge expandoBridge, PortletRequest portletRequest)
371         throws PortalException, SystemException {
372 
373         return getPortal().getExpandoBridgeAttributes(
374             expandoBridge, portletRequest);
375     }
376 
377     public static String getFacebookURL(
378             Portlet portlet, String facebookCanvasPageURL,
379             ThemeDisplay themeDisplay)
380         throws PortalException, SystemException {
381 
382         return getPortal().getFacebookURL(
383             portlet, facebookCanvasPageURL, themeDisplay);
384     }
385 
386     public static String getFirstPageLayoutTypes(PageContext pageContext) {
387         return getPortal().getFirstPageLayoutTypes(pageContext);
388     }
389 
390     public static String getGlobalLibDir() {
391         return getPortal().getGlobalLibDir();
392     }
393 
394     public static String getGoogleGadgetURL(
395         Portlet portlet, ThemeDisplay themeDisplay) {
396 
397         return getPortal().getGoogleGadgetURL(portlet, themeDisplay);
398     }
399 
400     public static String[] getGuestPermissions(HttpServletRequest request) {
401         return getPortal().getGuestPermissions(request);
402     }
403 
404     public static String[] getGuestPermissions(PortletRequest portletRequest) {
405         return getPortal().getGuestPermissions(portletRequest);
406     }
407 
408     public static String getHomeURL(HttpServletRequest request)
409         throws PortalException, SystemException {
410 
411         return getPortal().getHomeURL(request);
412     }
413 
414     public static String getHost(HttpServletRequest request) {
415         return getPortal().getHost(request);
416     }
417 
418     public static String getHost(PortletRequest portletRequest) {
419         return getPortal().getHost(portletRequest);
420     }
421 
422     public static HttpServletRequest getHttpServletRequest(
423         PortletRequest portletRequest) {
424 
425         return getPortal().getHttpServletRequest(portletRequest);
426     }
427 
428     public static HttpServletResponse getHttpServletResponse(
429         PortletResponse portletResponse) {
430 
431         return getPortal().getHttpServletResponse(portletResponse);
432     }
433 
434     public static String getJsSafePortletId(String portletId) {
435         return getPortal().getJsSafePortletId(portletId);
436     }
437 
438     public static String getLayoutActualURL(Layout layout) {
439         return getPortal().getLayoutActualURL(layout);
440     }
441 
442     public static String getLayoutActualURL(Layout layout, String mainPath) {
443         return getPortal().getLayoutActualURL(layout, mainPath);
444     }
445 
446     public static String getLayoutActualURL(
447             long groupId, boolean privateLayout, String mainPath,
448             String friendlyURL)
449         throws PortalException, SystemException {
450 
451         return getPortal().getLayoutActualURL(
452             groupId, privateLayout, mainPath, friendlyURL);
453     }
454 
455     public static String getLayoutActualURL(
456             long groupId, boolean privateLayout, String mainPath,
457             String friendlyURL, Map<String, String[]> params)
458         throws PortalException, SystemException {
459 
460         return getPortal().getLayoutActualURL(
461             groupId, privateLayout, mainPath, friendlyURL, params);
462     }
463 
464     public static String getLayoutEditPage(Layout layout) {
465         return getPortal().getLayoutEditPage(layout);
466     }
467 
468     public static String getLayoutEditPage(String type) {
469         return getPortal().getLayoutEditPage(type);
470     }
471 
472     public static String getLayoutFriendlyURL(
473         Layout layout, ThemeDisplay themeDisplay) {
474 
475         return getPortal().getLayoutFriendlyURL(layout, themeDisplay);
476     }
477 
478     public static String getLayoutFriendlyURL(
479         Layout layout, ThemeDisplay themeDisplay, Locale locale) {
480 
481         return getPortal().getLayoutFriendlyURL(layout, themeDisplay, locale);
482     }
483 
484     public static String getLayoutFullURL(
485         Layout layout, ThemeDisplay themeDisplay) {
486 
487         return getPortal().getLayoutFullURL(layout, themeDisplay);
488     }
489 
490     public static String getLayoutFullURL(
491         Layout layout, ThemeDisplay themeDisplay, boolean doAsUser) {
492 
493         return getPortal().getLayoutFullURL(layout, themeDisplay, doAsUser);
494     }
495 
496     public static String getLayoutFullURL(long groupId, String portletId)
497         throws PortalException, SystemException {
498 
499         return getPortal().getLayoutFullURL(groupId, portletId);
500     }
501 
502     public static String getLayoutFullURL(ThemeDisplay themeDisplay) {
503         return getPortal().getLayoutFullURL(themeDisplay);
504     }
505 
506     public static String getLayoutSetFriendlyURL(
507             LayoutSet layoutSet, ThemeDisplay themeDisplay)
508         throws PortalException, SystemException {
509 
510         return getPortal().getLayoutSetFriendlyURL(layoutSet, themeDisplay);
511     }
512 
513     public static String getLayoutTarget(Layout layout) {
514         return getPortal().getLayoutTarget(layout);
515     }
516 
517     public static String getLayoutURL(
518         Layout layout, ThemeDisplay themeDisplay) {
519 
520         return getPortal().getLayoutURL(layout, themeDisplay);
521     }
522 
523     public static String getLayoutURL(
524         Layout layout, ThemeDisplay themeDisplay, boolean doAsUser) {
525 
526         return getPortal().getLayoutURL(layout, themeDisplay, doAsUser);
527     }
528 
529     public static String getLayoutURL(ThemeDisplay themeDisplay) {
530         return getPortal().getLayoutURL(themeDisplay);
531     }
532 
533     public static String getLayoutViewPage(Layout layout) {
534         return getPortal().getLayoutViewPage(layout);
535     }
536 
537     public static String getLayoutViewPage(String type) {
538         return getPortal().getLayoutViewPage(type);
539     }
540 
541     public static LiferayPortletResponse getLiferayPortletResponse(
542         PortletResponse portletResponse) {
543 
544         return getPortal().getLiferayPortletResponse(portletResponse);
545     }
546 
547     public static Locale getLocale(HttpServletRequest request) {
548         return getPortal().getLocale(request);
549     }
550 
551     public static Locale getLocale(RenderRequest renderRequest) {
552         return getPortal().getLocale(renderRequest);
553     }
554 
555     /**
556      * @deprecated {@link #getBaseModel(Resource)}
557      */
558     public static BaseModel<?> getModel(Resource resource)
559         throws PortalException, SystemException {
560 
561         return getPortal().getBaseModel(resource);
562     }
563 
564     /**
565      * @deprecated {@link #getBaseModel(ResourcePermission)}
566      */
567     public static BaseModel<?> getModel(ResourcePermission resourcePermission)
568         throws PortalException, SystemException {
569 
570         return getPortal().getBaseModel(resourcePermission);
571     }
572 
573     /**
574      * @deprecated {@link #getBaseModel(String, String)}
575      */
576     public static BaseModel<?> getModel(String modelName, String primKey)
577         throws PortalException, SystemException {
578 
579         return getPortal().getBaseModel(modelName, primKey);
580     }
581 
582     public static String getNetvibesURL(
583         Portlet portlet, ThemeDisplay themeDisplay) {
584 
585         return getPortal().getNetvibesURL(portlet, themeDisplay);
586     }
587 
588     public static HttpServletRequest getOriginalServletRequest(
589         HttpServletRequest request) {
590 
591         return getPortal().getOriginalServletRequest(request);
592     }
593 
594     public static String getOuterPortletId(HttpServletRequest request) {
595         return getPortal().getOuterPortletId(request);
596     }
597 
598     public static long getParentGroupId(long scopeGroupId)
599         throws PortalException, SystemException {
600 
601         return getPortal().getParentGroupId(scopeGroupId);
602     }
603 
604     public static String getPathContext() {
605         return getPortal().getPathContext();
606     }
607 
608     public static String getPathFriendlyURLPrivateGroup() {
609         return getPortal().getPathFriendlyURLPrivateGroup();
610     }
611 
612     public static String getPathFriendlyURLPrivateUser() {
613         return getPortal().getPathFriendlyURLPrivateUser();
614     }
615 
616     public static String getPathFriendlyURLPublic() {
617         return getPortal().getPathFriendlyURLPublic();
618     }
619 
620     public static String getPathImage() {
621         return getPortal().getPathImage();
622     }
623 
624     public static String getPathMain() {
625         return getPortal().getPathMain();
626     }
627 
628     public static long getPlidFromFriendlyURL(
629         long companyId, String friendlyURL) {
630 
631         return getPortal().getPlidFromFriendlyURL(companyId, friendlyURL);
632     }
633 
634     public static long getPlidFromPortletId(
635         long groupId, boolean privateLayout, String portletId) {
636 
637         return getPortal().getPlidFromPortletId(
638             groupId, privateLayout, portletId);
639     }
640 
641     public static long getPlidFromPortletId(long groupId, String portletId) {
642         return getPortal().getPlidFromPortletId(groupId, portletId);
643     }
644 
645     public static Portal getPortal() {
646         return _portal;
647     }
648 
649     public static String getPortalLibDir() {
650         return getPortal().getPortalLibDir();
651     }
652 
653     public static int getPortalPort() {
654         return getPortal().getPortalPort();
655     }
656 
657     public static Properties getPortalProperties() {
658         return getPortal().getPortalProperties();
659     }
660 
661     public static String getPortalURL(HttpServletRequest request) {
662         return getPortal().getPortalURL(request);
663     }
664 
665     public static String getPortalURL(
666         HttpServletRequest request, boolean secure) {
667 
668         return getPortal().getPortalURL(request, secure);
669     }
670 
671     public static String getPortalURL(PortletRequest portletRequest) {
672         return getPortal().getPortalURL(portletRequest);
673     }
674 
675     public static String getPortalURL(
676         PortletRequest portletRequest, boolean secure) {
677 
678         return getPortal().getPortalURL(portletRequest, secure);
679     }
680 
681     public static String getPortalURL(
682         String serverName, int serverPort, boolean secure) {
683 
684         return getPortal().getPortalURL(serverName, serverPort, secure);
685     }
686 
687     public static String getPortalURL(ThemeDisplay themeDisplay) {
688         return getPortal().getPortalURL(themeDisplay);
689     }
690 
691     public static String getPortalWebDir() {
692         return getPortal().getPortalWebDir();
693     }
694 
695     public static Set<String> getPortletAddDefaultResourceCheckWhitelist() {
696         return getPortal().getPortletAddDefaultResourceCheckWhitelist();
697     }
698 
699     public static String getPortletDescription(
700         Portlet portlet, ServletContext servletContext, Locale locale) {
701 
702         return getPortal().getPortletDescription(
703             portlet, servletContext, locale);
704     }
705 
706     public static String getPortletDescription(Portlet portlet, User user) {
707         return getPortal().getPortletDescription(portlet, user);
708     }
709 
710     public static String getPortletDescription(
711         String portletId, Locale locale) {
712 
713         return getPortal().getPortletDescription(portletId, locale);
714     }
715 
716     /**
717      * @deprecated
718      */
719     public static String getPortletDescription(
720         String portletId, long companyId, Locale locale) {
721 
722         return getPortal().getPortletDescription(portletId, locale);
723     }
724 
725     /**
726      * @deprecated
727      */
728     public static String getPortletDescription(
729         String portletId, long companyId, String languageId) {
730 
731         return getPortal().getPortletDescription(portletId, languageId);
732     }
733 
734     public static String getPortletDescription(
735         String portletId, String languageId) {
736 
737         return getPortal().getPortletDescription(portletId, languageId);
738     }
739 
740     public static String getPortletDescription(String portletId, User user) {
741         return getPortal().getPortletDescription(portletId, user);
742     }
743 
744     public static Object[] getPortletFriendlyURLMapper(
745             long groupId, boolean privateLayout, String url)
746         throws PortalException, SystemException {
747 
748         return getPortal().getPortletFriendlyURLMapper(
749             groupId, privateLayout, url);
750     }
751 
752     public static Object[] getPortletFriendlyURLMapper(
753             long groupId, boolean privateLayout, String url,
754             Map<String, String[]> params)
755         throws PortalException, SystemException {
756 
757         return getPortal().getPortletFriendlyURLMapper(
758             groupId, privateLayout, url, params);
759     }
760 
761     /**
762      * @deprecated Use <code>getScopeGroupId</code>.
763      */
764     public static long getPortletGroupId(ActionRequest actionRequest) {
765         return getPortal().getPortletGroupId(actionRequest);
766     }
767 
768     /**
769      * @deprecated Use <code>getScopeGroupId</code>.
770      */
771     public static long getPortletGroupId(HttpServletRequest request) {
772         return getPortal().getPortletGroupId(request);
773     }
774 
775     /**
776      * @deprecated Use <code>getScopeGroupId</code>.
777      */
778     public static long getPortletGroupId(Layout layout) {
779         return getPortal().getPortletGroupId(layout);
780     }
781 
782     /**
783      * @deprecated Use <code>getScopeGroupId</code>.
784      */
785     public static long getPortletGroupId(long plid) {
786         return getPortal().getPortletGroupId(plid);
787     }
788 
789     /**
790      * @deprecated Use <code>getScopeGroupId</code>.
791      */
792     public static long getPortletGroupId(RenderRequest renderRequest) {
793         return getPortal().getPortletGroupId(renderRequest);
794     }
795 
796     public static String getPortletId(HttpServletRequest request) {
797         return getPortal().getPortletId(request);
798     }
799 
800     public static String getPortletId(PortletRequest portletRequest) {
801         return getPortal().getPortletId(portletRequest);
802     }
803 
804     public static String getPortletNamespace(String portletId) {
805         return getPortal().getPortletNamespace(portletId);
806     }
807 
808     public static String getPortletTitle(Portlet portlet, Locale locale) {
809         return getPortal().getPortletTitle(portlet, locale);
810     }
811 
812     /**
813      * @deprecated
814      */
815     public static String getPortletTitle(
816         Portlet portlet, long companyId, Locale locale) {
817 
818         return getPortal().getPortletTitle(portlet, locale);
819     }
820 
821     /**
822      * @deprecated
823      */
824     public static String getPortletTitle(
825         Portlet portlet, long companyId, String languageId) {
826 
827         return getPortal().getPortletTitle(portlet, languageId);
828     }
829 
830     public static String getPortletTitle(
831         Portlet portlet, ServletContext servletContext, Locale locale) {
832 
833         return getPortal().getPortletTitle(portlet, servletContext, locale);
834     }
835 
836     public static String getPortletTitle(Portlet portlet, String languageId) {
837         return getPortal().getPortletTitle(portlet, languageId);
838     }
839 
840     public static String getPortletTitle(Portlet portlet, User user) {
841         return getPortal().getPortletTitle(portlet, user);
842     }
843 
844     public static String getPortletTitle(RenderResponse renderResponse) {
845         return getPortal().getPortletTitle(renderResponse);
846     }
847 
848     public static String getPortletTitle(String portletId, Locale locale) {
849         return getPortal().getPortletTitle(portletId, locale);
850     }
851 
852     /**
853      * @deprecated
854      */
855     public static String getPortletTitle(
856         String portletId, long companyId, Locale locale) {
857 
858         return getPortal().getPortletTitle(portletId, locale);
859     }
860 
861     /**
862      * @deprecated
863      */
864     public static String getPortletTitle(
865         String portletId, long companyId, String languageId) {
866 
867         return getPortal().getPortletTitle(portletId, languageId);
868     }
869 
870     public static String getPortletTitle(String portletId, String languageId) {
871         return getPortal().getPortletTitle(portletId, languageId);
872     }
873 
874     public static String getPortletTitle(String portletId, User user) {
875         return getPortal().getPortletTitle(portletId, user);
876     }
877 
878     public static String getPortletXmlFileName() throws SystemException {
879         return getPortal().getPortletXmlFileName();
880     }
881 
882     public static PortletPreferences getPreferences(
883         HttpServletRequest request) {
884 
885         return getPortal().getPreferences(request);
886     }
887 
888     public static PreferencesValidator getPreferencesValidator(
889         Portlet portlet) {
890 
891         return getPortal().getPreferencesValidator(portlet);
892     }
893 
894     public static long getScopeGroupId(HttpServletRequest request) {
895         return getPortal().getScopeGroupId(request);
896     }
897 
898     public static long getScopeGroupId(
899         HttpServletRequest request, String portletId) {
900 
901         return getPortal().getScopeGroupId(request, portletId);
902     }
903 
904     public static long getScopeGroupId(Layout layout) {
905         return getPortal().getScopeGroupId(layout);
906     }
907 
908     public static long getScopeGroupId(Layout layout, String portletId) {
909         return getPortal().getScopeGroupId(layout, portletId);
910     }
911 
912     public static long getScopeGroupId(long plid) {
913         return getPortal().getScopeGroupId(plid);
914     }
915 
916     public static long getScopeGroupId(PortletRequest portletRequest) {
917         return getPortal().getScopeGroupId(portletRequest);
918     }
919 
920     public static User getSelectedUser(HttpServletRequest request)
921         throws PortalException, SystemException {
922 
923         return getPortal().getSelectedUser(request);
924     }
925 
926     public static User getSelectedUser(
927             HttpServletRequest request, boolean checkPermission)
928         throws PortalException, SystemException {
929 
930         return getPortal().getSelectedUser(request, checkPermission);
931     }
932 
933     public static User getSelectedUser(PortletRequest portletRequest)
934         throws PortalException, SystemException {
935 
936         return getPortal().getSelectedUser(portletRequest);
937     }
938 
939     public static User getSelectedUser(
940             PortletRequest portletRequest, boolean checkPermission)
941         throws PortalException, SystemException {
942 
943         return getPortal().getSelectedUser(portletRequest, checkPermission);
944     }
945 
946     public static ServletContext getServletContext(
947         Portlet portlet, ServletContext servletContext) {
948 
949         return getPortal().getServletContext(portlet, servletContext);
950     }
951 
952     public static String getStaticResourceURL(
953         HttpServletRequest request, String uri) {
954 
955         return getPortal().getStaticResourceURL(request, uri);
956     }
957 
958     public static String getStaticResourceURL(
959         HttpServletRequest request, String uri, long timestamp) {
960 
961         return getPortal().getStaticResourceURL(request, uri, timestamp);
962     }
963 
964     public static String getStaticResourceURL(
965         HttpServletRequest request, String uri, String queryString) {
966 
967         return getPortal().getStaticResourceURL(request, uri, queryString);
968     }
969 
970     public static String getStaticResourceURL(
971         HttpServletRequest request, String uri, String queryString,
972         long timestamp) {
973 
974         return getPortal().getStaticResourceURL(
975             request, uri, queryString, timestamp);
976     }
977 
978     public static String getStrutsAction(HttpServletRequest request) {
979         return getPortal().getStrutsAction(request);
980     }
981 
982     public static String[] getSystemCommunityRoles() {
983         return getPortal().getSystemCommunityRoles();
984     }
985 
986     public static String[] getSystemGroups() {
987         return getPortal().getSystemGroups();
988     }
989 
990     public static String[] getSystemOrganizationRoles() {
991         return getPortal().getSystemOrganizationRoles();
992     }
993 
994     public static String[] getSystemRoles() {
995         return getPortal().getSystemRoles();
996     }
997 
998     public static String[] getTagsCategories(PortletRequest portletRequest) {
999         return getPortal().getTagsCategories(portletRequest);
1000    }
1001
1002    public static String[] getTagsEntries(PortletRequest portletRequest) {
1003        return getPortal().getTagsEntries(portletRequest);
1004    }
1005
1006    public static UploadPortletRequest getUploadPortletRequest(
1007        PortletRequest portletRequest) {
1008
1009        return getPortal().getUploadPortletRequest(portletRequest);
1010    }
1011
1012    public static UploadServletRequest getUploadServletRequest(
1013        HttpServletRequest request) {
1014
1015        return getPortal().getUploadServletRequest(request);
1016    }
1017
1018    public static Date getUptime() {
1019        return getPortal().getUptime();
1020    }
1021
1022    public static String getURLWithSessionId(String url, String sessionId) {
1023        return getPortal().getURLWithSessionId(url, sessionId);
1024    }
1025
1026    public static User getUser(HttpServletRequest request)
1027        throws PortalException, SystemException {
1028
1029        return getPortal().getUser(request);
1030    }
1031
1032    public static User getUser(PortletRequest portletRequest)
1033        throws PortalException, SystemException {
1034
1035        return getPortal().getUser(portletRequest);
1036    }
1037
1038    public static long getUserId(HttpServletRequest request) {
1039        return getPortal().getUserId(request);
1040    }
1041
1042    public static long getUserId(PortletRequest portletRequest) {
1043        return getPortal().getUserId(portletRequest);
1044    }
1045
1046    public static String getUserName(long userId, String defaultUserName) {
1047        return getPortal().getUserName(userId, defaultUserName);
1048    }
1049
1050    public static String getUserName(
1051        long userId, String defaultUserName, HttpServletRequest request) {
1052
1053        return getPortal().getUserName(userId, defaultUserName, request);
1054    }
1055
1056    public static String getUserName(
1057        long userId, String defaultUserName, String userAttribute) {
1058
1059        return getPortal().getUserName(userId, defaultUserName, userAttribute);
1060    }
1061
1062    public static String getUserName(
1063        long userId, String defaultUserName, String userAttribute,
1064        HttpServletRequest request) {
1065
1066        return getPortal().getUserName(
1067            userId, defaultUserName, userAttribute, request);
1068    }
1069
1070    public static String getUserPassword(HttpServletRequest request) {
1071        return getPortal().getUserPassword(request);
1072    }
1073
1074    public static String getUserPassword(HttpSession session) {
1075        return getPortal().getUserPassword(session);
1076    }
1077
1078    public static String getUserPassword(PortletRequest portletRequest) {
1079        return getPortal().getUserPassword(portletRequest);
1080    }
1081
1082    public static String getUserValue(
1083            long userId, String param, String defaultValue)
1084        throws SystemException {
1085
1086        return getPortal().getUserValue(userId, param, defaultValue);
1087    }
1088
1089    public static long getValidUserId(long companyId, long userId)
1090        throws PortalException, SystemException {
1091
1092        return getPortal().getValidUserId(companyId, userId);
1093    }
1094
1095    public static String getWidgetURL(
1096        Portlet portlet, ThemeDisplay themeDisplay) {
1097
1098        return getPortal().getWidgetURL(portlet, themeDisplay);
1099    }
1100
1101    public static boolean isAllowAddPortletDefaultResource(
1102            HttpServletRequest request, Portlet portlet)
1103        throws PortalException, SystemException {
1104
1105        return getPortal().isAllowAddPortletDefaultResource(request, portlet);
1106    }
1107
1108    public static boolean isCommunityAdmin(User user, long groupId)
1109        throws Exception {
1110
1111        return getPortal().isCommunityAdmin(user, groupId);
1112    }
1113
1114    public static boolean isCommunityOwner(User user, long groupId)
1115        throws Exception {
1116
1117        return getPortal().isCommunityOwner(user, groupId);
1118    }
1119
1120    public static boolean isCompanyAdmin(User user) throws Exception {
1121        return getPortal().isCompanyAdmin(user);
1122    }
1123
1124    public static boolean isControlPanelPortlet(
1125            String portletId, String category, ThemeDisplay themeDisplay)
1126        throws SystemException {
1127
1128        return getPortal().isControlPanelPortlet(
1129            portletId, category, themeDisplay);
1130    }
1131
1132    public static boolean isControlPanelPortlet(
1133            String portletId, ThemeDisplay themeDisplay)
1134        throws SystemException {
1135
1136        return getPortal().isControlPanelPortlet(portletId, themeDisplay);
1137    }
1138
1139    public static boolean isLayoutFirstPageable(Layout layout) {
1140        return getPortal().isLayoutFirstPageable(layout);
1141    }
1142
1143    public static boolean isLayoutFirstPageable(String type) {
1144        return getPortal().isLayoutFirstPageable(type);
1145    }
1146
1147    public static boolean isLayoutFriendliable(Layout layout) {
1148        return getPortal().isLayoutFriendliable(layout);
1149    }
1150
1151    public static boolean isLayoutFriendliable(String type) {
1152        return getPortal().isLayoutFriendliable(type);
1153    }
1154
1155    public static boolean isLayoutParentable(Layout layout) {
1156        return getPortal().isLayoutParentable(layout);
1157    }
1158
1159    public static boolean isLayoutParentable(String type) {
1160        return getPortal().isLayoutParentable(type);
1161    }
1162
1163    public static boolean isLayoutSitemapable(Layout layout) {
1164        return getPortal().isLayoutSitemapable(layout);
1165    }
1166
1167    public static boolean isMethodGet(PortletRequest portletRequest) {
1168        return getPortal().isMethodGet(portletRequest);
1169    }
1170
1171    public static boolean isMethodPost(PortletRequest portletRequest) {
1172        return getPortal().isMethodPost(portletRequest);
1173    }
1174
1175    public static boolean isOmniadmin(long userId) {
1176        return getPortal().isOmniadmin(userId);
1177    }
1178
1179    public static boolean isReservedParameter(String name) {
1180        return getPortal().isReservedParameter(name);
1181    }
1182
1183    public static boolean isSystemGroup(String groupName) {
1184        return getPortal().isSystemGroup(groupName);
1185    }
1186
1187    public static boolean isSystemRole(String roleName) {
1188        return getPortal().isSystemRole(roleName);
1189    }
1190
1191    public static boolean isUpdateAvailable() throws SystemException {
1192        return getPortal().isUpdateAvailable();
1193    }
1194
1195    public static boolean isValidResourceId(String resourceId) {
1196        return getPortal().isValidResourceId(resourceId);
1197    }
1198
1199    public void removePortalPortEventListener(
1200        PortalPortEventListener portalPortEventListener) {
1201
1202        getPortal().removePortalPortEventListener(portalPortEventListener);
1203    }
1204
1205    public static String renderPage(
1206            ServletContext servletContext, HttpServletRequest request,
1207            HttpServletResponse response, String path, boolean writeOutput)
1208        throws IOException, ServletException {
1209
1210        return getPortal().renderPage(servletContext, request, response, path);
1211    }
1212
1213    public static String renderPortlet(
1214            ServletContext servletContext, HttpServletRequest request,
1215            HttpServletResponse response, Portlet portlet, String queryString,
1216            boolean writeOutput)
1217        throws IOException, ServletException {
1218
1219        return getPortal().renderPortlet(
1220            servletContext, request, response, portlet, queryString,
1221            writeOutput);
1222    }
1223
1224    public static String renderPortlet(
1225            ServletContext servletContext, HttpServletRequest request,
1226            HttpServletResponse response, Portlet portlet, String queryString,
1227            String columnId, Integer columnPos, Integer columnCount,
1228            boolean writeOutput)
1229        throws IOException, ServletException {
1230
1231        return getPortal().renderPortlet(
1232            servletContext, request, response, portlet, queryString, columnId,
1233            columnPos, columnCount, writeOutput);
1234    }
1235
1236    public static String renderPortlet(
1237            ServletContext servletContext, HttpServletRequest request,
1238            HttpServletResponse response, Portlet portlet, String queryString,
1239            String columnId, Integer columnPos, Integer columnCount,
1240            String path, boolean writeOutput)
1241        throws IOException, ServletException {
1242
1243        return getPortal().renderPortlet(
1244            servletContext, request, response, portlet, queryString, columnId,
1245            columnPos, columnCount, path, writeOutput);
1246    }
1247
1248    /**
1249     * @deprecated {@link DB#runSQL(String)}
1250     */
1251    public static void runSQL(String sql) throws IOException, SQLException {
1252        DBFactoryUtil.getDB().runSQL(sql);
1253    }
1254
1255    public static void sendError(
1256            Exception e, ActionRequest actionRequest,
1257            ActionResponse actionResponse)
1258        throws IOException {
1259
1260        getPortal().sendError(e, actionRequest, actionResponse);
1261    }
1262
1263    public static void sendError(
1264            Exception e, HttpServletRequest request,
1265            HttpServletResponse response)
1266        throws IOException, ServletException {
1267
1268        getPortal().sendError(e, request, response);
1269    }
1270
1271    public static void sendError(
1272            int status, Exception e, ActionRequest actionRequest,
1273            ActionResponse actionResponse)
1274        throws IOException {
1275
1276        getPortal().sendError(status, e, actionRequest, actionResponse);
1277    }
1278
1279    public static void sendError(
1280            int status, Exception e, HttpServletRequest request,
1281            HttpServletResponse response)
1282        throws IOException, ServletException {
1283
1284        getPortal().sendError(status, e, request, response);
1285    }
1286
1287    /**
1288     * Sets the description for a page. This overrides the existing page
1289     * description.
1290     */
1291    public static void setPageDescription(
1292        String description, HttpServletRequest request) {
1293
1294        getPortal().setPageDescription(description, request);
1295    }
1296
1297    /**
1298     * Sets the keywords for a page. This overrides the existing page keywords.
1299     */
1300    public static void setPageKeywords(
1301        String keywords, HttpServletRequest request) {
1302
1303        getPortal().setPageKeywords(keywords, request);
1304    }
1305
1306    /**
1307     * Sets the subtitle for a page. This overrides the existing page subtitle.
1308     */
1309    public static void setPageSubtitle(
1310        String subtitle, HttpServletRequest request) {
1311
1312        getPortal().setPageSubtitle(subtitle, request);
1313    }
1314
1315    /**
1316     * Sets the whole title for a page. This overrides the existing page whole
1317     * title.
1318     */
1319    public static void setPageTitle(
1320        String title, HttpServletRequest request) {
1321
1322        getPortal().setPageTitle(title, request);
1323    }
1324
1325    /**
1326     * Sets the port obtained on the first request to the portal.
1327     */
1328    public static void setPortalPort(HttpServletRequest request) {
1329        getPortal().setPortalPort(request);
1330    }
1331
1332    public static void storePreferences(PortletPreferences preferences)
1333        throws IOException, ValidatorException {
1334
1335        getPortal().storePreferences(preferences);
1336    }
1337
1338    public static String transformCustomSQL(String sql) {
1339        return getPortal().transformCustomSQL(sql);
1340    }
1341
1342    public static PortletMode updatePortletMode(
1343        String portletId, User user, Layout layout, PortletMode portletMode,
1344        HttpServletRequest request) {
1345
1346        return getPortal().updatePortletMode(
1347            portletId, user, layout, portletMode, request);
1348    }
1349
1350    public static WindowState updateWindowState(
1351        String portletId, User user, Layout layout, WindowState windowState,
1352        HttpServletRequest request) {
1353
1354        return getPortal().updateWindowState(
1355            portletId, user, layout, windowState, request);
1356    }
1357
1358    public void setPortal(Portal portal) {
1359        _portal = portal;
1360    }
1361
1362    private static Portal _portal;
1363
1364}