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