001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.theme;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.language.LanguageUtil;
020    import com.liferay.portal.kernel.log.Log;
021    import com.liferay.portal.kernel.log.LogFactoryUtil;
022    import com.liferay.portal.kernel.mobile.device.Device;
023    import com.liferay.portal.kernel.staging.StagingUtil;
024    import com.liferay.portal.kernel.util.Http;
025    import com.liferay.portal.kernel.util.LocaleThreadLocal;
026    import com.liferay.portal.kernel.util.Mergeable;
027    import com.liferay.portal.kernel.util.StringPool;
028    import com.liferay.portal.kernel.util.TimeZoneThreadLocal;
029    import com.liferay.portal.kernel.util.Validator;
030    import com.liferay.portal.model.Account;
031    import com.liferay.portal.model.ColorScheme;
032    import com.liferay.portal.model.Company;
033    import com.liferay.portal.model.Contact;
034    import com.liferay.portal.model.Group;
035    import com.liferay.portal.model.Layout;
036    import com.liferay.portal.model.LayoutSet;
037    import com.liferay.portal.model.LayoutTypePortlet;
038    import com.liferay.portal.model.Theme;
039    import com.liferay.portal.model.ThemeSetting;
040    import com.liferay.portal.model.User;
041    import com.liferay.portal.security.permission.PermissionChecker;
042    import com.liferay.portal.service.GroupLocalServiceUtil;
043    import com.liferay.portal.service.LayoutLocalServiceUtil;
044    import com.liferay.portal.util.PortalUtil;
045    import com.liferay.portlet.mobiledevicerules.model.MDRRuleGroupInstance;
046    
047    import java.io.Serializable;
048    
049    import java.util.List;
050    import java.util.Locale;
051    import java.util.Map;
052    import java.util.Properties;
053    import java.util.TimeZone;
054    
055    import javax.portlet.PortletURL;
056    
057    import javax.servlet.http.HttpServletRequest;
058    
059    /**
060     * @author Brian Wing Shun Chan
061     */
062    public class ThemeDisplay
063            implements Cloneable, Mergeable<ThemeDisplay>, Serializable {
064    
065            public ThemeDisplay() {
066                    if (_log.isDebugEnabled()) {
067                            _log.debug("Creating new instance " + hashCode());
068                    }
069    
070                    _portletDisplay.setThemeDisplay(this);
071            }
072    
073            @Override
074            public Object clone() throws CloneNotSupportedException {
075                    ThemeDisplay themeDisplay = (ThemeDisplay)super.clone();
076    
077                    PortletDisplay portletDisplay = new PortletDisplay();
078    
079                    _portletDisplay.copyTo(portletDisplay);
080    
081                    themeDisplay._portletDisplay = portletDisplay;
082    
083                    portletDisplay.setThemeDisplay(themeDisplay);
084    
085                    return themeDisplay;
086            }
087    
088            public Account getAccount() {
089                    return _account;
090            }
091    
092            public String getCDNBaseURL() {
093                    if (_cdnBaseURL != null) {
094                            return _cdnBaseURL;
095                    }
096    
097                    String host = getCDNHost();
098    
099                    String portalURL = getPortalURL();
100    
101                    if (getServerName() != null) {
102                            try {
103                                    portalURL = PortalUtil.getPortalURL(getLayout(), this);
104                            }
105                            catch (Exception e) {
106                                    _log.error(e, e);
107                            }
108                    }
109    
110                    if (Validator.isNull(host)) {
111                            host = portalURL;
112                    }
113    
114                    _cdnBaseURL = host;
115    
116                    return _cdnBaseURL;
117            }
118    
119            public String getCDNDynamicResourcesHost() {
120                    return _cdnDynamicResourcesHost;
121            }
122    
123            public String getCDNHost() {
124                    return _cdnHost;
125            }
126    
127            public ColorScheme getColorScheme() {
128                    return _colorScheme;
129            }
130    
131            public String getColorSchemeId() {
132                    return _colorScheme.getColorSchemeId();
133            }
134    
135            public Company getCompany() {
136                    return _company;
137            }
138    
139            public long getCompanyGroupId() {
140                    return _companyGroupId;
141            }
142    
143            public long getCompanyId() {
144                    return _company.getCompanyId();
145            }
146    
147            public String getCompanyLogo() {
148                    return _companyLogo;
149            }
150    
151            public int getCompanyLogoHeight() {
152                    return _companyLogoHeight;
153            }
154    
155            public int getCompanyLogoWidth() {
156                    return _companyLogoWidth;
157            }
158    
159            public Contact getContact() {
160                    return _contact;
161            }
162    
163            public String getControlPanelCategory() {
164                    return _controlPanelCategory;
165            }
166    
167            public User getDefaultUser() throws PortalException, SystemException {
168                    if (_defaultUser == null) {
169                            _defaultUser = _company.getDefaultUser();
170                    }
171    
172                    return _defaultUser;
173            }
174    
175            public long getDefaultUserId() throws PortalException, SystemException {
176                    return getDefaultUser().getUserId();
177            }
178    
179            public Device getDevice() {
180                    return _device;
181            }
182    
183            public long getDoAsGroupId() {
184                    return _doAsGroupId;
185            }
186    
187            public String getDoAsUserId() {
188                    return _doAsUserId;
189            }
190    
191            public String getDoAsUserLanguageId() {
192                    return _doAsUserLanguageId;
193            }
194    
195            public String getFacebookCanvasPageURL() {
196                    return _facebookCanvasPageURL;
197            }
198    
199            public String getI18nLanguageId() {
200                    return _i18nLanguageId;
201            }
202    
203            public String getI18nPath() {
204                    return _i18nPath;
205            }
206    
207            public String getLanguageId() {
208                    return _languageId;
209            }
210    
211            public Layout getLayout() {
212                    return _layout;
213            }
214    
215            public List<Layout> getLayouts() {
216                    return _layouts;
217            }
218    
219            public LayoutSet getLayoutSet() {
220                    return _layoutSet;
221            }
222    
223            public String getLayoutSetLogo() {
224                    return _layoutSetLogo;
225            }
226    
227            public LayoutTypePortlet getLayoutTypePortlet() {
228                    return _layoutTypePortlet;
229            }
230    
231            public String getLifecycle() {
232                    return _lifecycle;
233            }
234    
235            public Locale getLocale() {
236                    return _locale;
237            }
238    
239            public MDRRuleGroupInstance getMDRRuleGroupInstance() {
240                    return _mdrRuleGroupInstance;
241            }
242    
243            /**
244             * @deprecated As of 6.2.0 renamed to {@link #getSiteGroup}
245             */
246            public Group getParentGroup() {
247                    return getSiteGroup();
248            }
249    
250            /**
251             * @deprecated As of 6.2.0 renamed to {@link #getSiteGroupId}
252             */
253            public long getParentGroupId() {
254                    return getSiteGroupId();
255            }
256    
257            /**
258             * @deprecated As of 6.2.0 renamed to {@link #getSiteGroupName}
259             */
260            public String getParentGroupName() throws PortalException, SystemException {
261                    return getSiteGroupName();
262            }
263    
264            public String getPathApplet() {
265                    return _pathApplet;
266            }
267    
268            public String getPathCms() {
269                    return _pathCms;
270            }
271    
272            public String getPathColorSchemeImages() {
273                    return _pathColorSchemeImages;
274            }
275    
276            public String getPathContext() {
277                    return _pathContext;
278            }
279    
280            public String getPathFlash() {
281                    return _pathFlash;
282            }
283    
284            public String getPathFriendlyURLPrivateGroup() {
285                    return _pathFriendlyURLPrivateGroup;
286            }
287    
288            public String getPathFriendlyURLPrivateUser() {
289                    return _pathFriendlyURLPrivateUser;
290            }
291    
292            public String getPathFriendlyURLPublic() {
293                    return _pathFriendlyURLPublic;
294            }
295    
296            public String getPathImage() {
297                    return _pathImage;
298            }
299    
300            public String getPathJavaScript() {
301                    return _pathJavaScript;
302            }
303    
304            public String getPathMain() {
305                    return _pathMain;
306            }
307    
308            public String getPathSound() {
309                    return _pathSound;
310            }
311    
312            public String getPathThemeCss() {
313                    return _pathThemeCss;
314            }
315    
316            /**
317             * @deprecated As of 6.2.0, replaced by {@link #getPathThemeImages}
318             */
319            public String getPathThemeImage() {
320                    return getPathThemeImages();
321            }
322    
323            public String getPathThemeImages() {
324                    return _pathThemeImages;
325            }
326    
327            public String getPathThemeJavaScript() {
328                    return _pathThemeJavaScript;
329            }
330    
331            public String getPathThemeRoot() {
332                    return _pathThemeRoot;
333            }
334    
335            public String getPathThemeTemplates() {
336                    return _pathThemeTemplates;
337            }
338    
339            public PermissionChecker getPermissionChecker() {
340                    return _permissionChecker;
341            }
342    
343            public long getPlid() {
344                    return _plid;
345            }
346    
347            public String getPortalURL() {
348                    return _portalURL;
349            }
350    
351            public PortletDisplay getPortletDisplay() {
352                    return _portletDisplay;
353            }
354    
355            /**
356             * @deprecated As of 6.2.0, replaced by {@link #getScopeGroupId}
357             */
358            public long getPortletGroupId() {
359                    return getScopeGroupId();
360            }
361    
362            public String getPpid() {
363                    return _ppid;
364            }
365    
366            public String getRealCompanyLogo() {
367                    return _realCompanyLogo;
368            }
369    
370            public int getRealCompanyLogoHeight() {
371                    return _realCompanyLogoHeight;
372            }
373    
374            public int getRealCompanyLogoWidth() {
375                    return _realCompanyLogoWidth;
376            }
377    
378            public User getRealUser() {
379                    return _realUser;
380            }
381    
382            public long getRealUserId() {
383                    return _realUser.getUserId();
384            }
385    
386            public long getRefererGroupId() {
387                    return _refererGroupId;
388            }
389    
390            public long getRefererPlid() {
391                    return _refererPlid;
392            }
393    
394            public HttpServletRequest getRequest() {
395                    return _request;
396            }
397    
398            public Group getScopeGroup() {
399                    return _scopeGroup;
400            }
401    
402            public long getScopeGroupId() {
403                    return _scopeGroupId;
404            }
405    
406            /**
407             * @deprecated As of 6.2.0 renamed to {@link #getSiteGroupIdOrLiveGroupId}
408             */
409            public long getScopeGroupIdOrLiveGroupId()
410                    throws PortalException, SystemException {
411    
412                    return getSiteGroupIdOrLiveGroupId();
413            }
414    
415            public String getScopeGroupName() throws PortalException, SystemException {
416                    if (_scopeGroup == null) {
417                            return StringPool.BLANK;
418                    }
419    
420                    return _scopeGroup.getDescriptiveName();
421            }
422    
423            public Layout getScopeLayout() throws PortalException, SystemException {
424                    if (_layout.hasScopeGroup()) {
425                            return _layout;
426                    }
427                    else if (_scopeGroup.isLayout()) {
428                            return LayoutLocalServiceUtil.getLayout(_scopeGroup.getClassPK());
429                    }
430                    else {
431                            return null;
432                    }
433            }
434    
435            public String getServerName() {
436                    return _serverName;
437            }
438    
439            public int getServerPort() {
440                    return _serverPort;
441            }
442    
443            public String getSessionId() {
444                    return _sessionId;
445            }
446    
447            public Locale getSiteDefaultLocale() {
448                    return _siteDefaultLocale;
449            }
450    
451            public Group getSiteGroup() {
452                    return _siteGroup;
453            }
454    
455            public long getSiteGroupId() {
456                    return _siteGroupId;
457            }
458    
459            public long getSiteGroupIdOrLiveGroupId()
460                    throws PortalException, SystemException {
461    
462                    return StagingUtil.getLiveGroupId(_siteGroupId);
463            }
464    
465            public String getSiteGroupName() throws PortalException, SystemException {
466                    if (_siteGroup == null) {
467                            return StringPool.BLANK;
468                    }
469    
470                    return _siteGroup.getDescriptiveName();
471            }
472    
473            public Theme getTheme() {
474                    return _theme;
475            }
476    
477            public String getThemeId() {
478                    return _theme.getThemeId();
479            }
480    
481            public String getThemeSetting(String key) {
482                    Theme theme = getTheme();
483    
484                    String device = theme.getDevice();
485    
486                    Layout layout = getLayout();
487    
488                    return layout.getThemeSetting(key, device);
489            }
490    
491            public Properties getThemeSettings() {
492                    Theme theme = getTheme();
493    
494                    Properties properties = new Properties();
495    
496                    Map<String, ThemeSetting> themeSettings = theme.getSettings();
497    
498                    for (String key : themeSettings.keySet()) {
499                            ThemeSetting themeSetting = themeSettings.get(key);
500    
501                            String value = null;
502    
503                            if (themeSetting.isConfigurable()) {
504                                    value = getThemeSetting(key);
505                            }
506                            else {
507                                    value = themeSetting.getValue();
508                            }
509    
510                            if (value != null) {
511                                    properties.put(key, value);
512                            }
513                    }
514    
515                    return properties;
516            }
517    
518            public String getTilesContent() {
519                    return _tilesContent;
520            }
521    
522            public String getTilesTitle() {
523                    return _tilesTitle;
524            }
525    
526            public TimeZone getTimeZone() {
527                    return _timeZone;
528            }
529    
530            public List<Layout> getUnfilteredLayouts() {
531                    return _unfilteredLayouts;
532            }
533    
534            public String getURLAddContent() {
535                    return _urlAddContent;
536            }
537    
538            public String getURLControlPanel() {
539                    return _urlControlPanel;
540            }
541    
542            public String getURLCurrent() {
543                    return _urlCurrent;
544            }
545    
546            public String getURLHome() {
547                    return _urlHome;
548            }
549    
550            public String getURLLayoutTemplates() {
551                    if (Validator.isNull(_urlLayoutTemplates)) {
552                            return _urlPageSettings + "#layout";
553                    }
554    
555                    return _urlLayoutTemplates;
556            }
557    
558            /**
559             * @deprecated As of 6.2.0, replaced by {@link #getURLSiteAdministration()}
560             */
561            public PortletURL getURLManageSiteMemberships() {
562                    return _urlManageSiteMemberships;
563            }
564    
565            public PortletURL getURLMyAccount() {
566                    return _urlMyAccount;
567            }
568    
569            public PortletURL getURLPageSettings() {
570                    return _urlPageSettings;
571            }
572    
573            public String getURLPortal() {
574                    return _urlPortal;
575            }
576    
577            public PortletURL getURLPublishToLive() {
578                    return _urlPublishToLive;
579            }
580    
581            public String getURLSignIn() {
582                    return _urlSignIn;
583            }
584    
585            public String getURLSignOut() {
586                    return _urlSignOut;
587            }
588    
589            public String getURLSiteAdministration() {
590                    return _urlSiteAdministration;
591            }
592    
593            /**
594             * @deprecated As of 6.2.0, replaced by {@link #getURLSiteAdministration()}
595             */
596            public String getURLSiteContent() {
597                    return getURLSiteAdministration();
598            }
599    
600            /**
601             * @deprecated As of 6.2.0, replaced by {@link
602             *             #isShowSiteAdministrationIcon()}
603             */
604            public PortletURL getURLSiteMapSettings() {
605                    return _urlSiteMapSettings;
606            }
607    
608            /**
609             * @deprecated As of 6.2.0, replaced by {@link #getURLSiteAdministration()}
610             */
611            public PortletURL getURLSiteSettings() {
612                    return _urlSiteSettings;
613            }
614    
615            public PortletURL getURLUpdateManager() {
616                    return _urlUpdateManager;
617            }
618    
619            public User getUser() {
620                    return _user;
621            }
622    
623            public long getUserId() {
624                    return _user.getUserId();
625            }
626    
627            public boolean isAddSessionIdToURL() {
628                    return _addSessionIdToURL;
629            }
630    
631            public boolean isAjax() {
632                    return _ajax;
633            }
634    
635            public boolean isFacebook() {
636                    return _facebook;
637            }
638    
639            public boolean isFreeformLayout() {
640                    return _freeformLayout;
641            }
642    
643            public boolean isI18n() {
644                    return _i18n;
645            }
646    
647            public boolean isImpersonated() {
648                    if (getUserId() == getRealUserId()) {
649                            return false;
650                    }
651    
652                    return true;
653            }
654    
655            public boolean isIncludedJs(String js) {
656                    String path = getPathJavaScript();
657    
658                    if (isIncludePortletCssJs() &&
659                            js.startsWith(path + "/liferay/portlet_css.js")) {
660    
661                            return true;
662                    }
663    
664                    return false;
665            }
666    
667            public boolean isIncludePortletCssJs() {
668                    return _includePortletCssJs;
669            }
670    
671            public boolean isIsolated() {
672                    return _isolated;
673            }
674    
675            public boolean isLifecycleAction() {
676                    return _lifecycleAction;
677            }
678    
679            public boolean isLifecycleEvent() {
680                    return _lifecycleEvent;
681            }
682    
683            public boolean isLifecycleRender() {
684                    return _lifecycleRender;
685            }
686    
687            public boolean isLifecycleResource() {
688                    return _lifecycleResource;
689            }
690    
691            public boolean isSecure() {
692                    return _secure;
693            }
694    
695            public boolean isShowAddContentIcon() {
696                    return _showAddContentIcon;
697            }
698    
699            public boolean isShowAddContentIconPermission() {
700                    return _showAddContentIconPermission;
701            }
702    
703            public boolean isShowControlPanelIcon() {
704                    return _showControlPanelIcon;
705            }
706    
707            public boolean isShowHomeIcon() {
708                    return _showHomeIcon;
709            }
710    
711            public boolean isShowLayoutTemplatesIcon() {
712                    return _showLayoutTemplatesIcon;
713            }
714    
715            /**
716             * @deprecated As of 6.2.0, replaced by {@link
717             *             #isShowSiteAdministrationIcon()}
718             */
719            public boolean isShowManageSiteMembershipsIcon() {
720                    return _showManageSiteMembershipsIcon;
721            }
722    
723            public boolean isShowMyAccountIcon() {
724                    return _showMyAccountIcon;
725            }
726    
727            public boolean isShowPageCustomizationIcon() {
728                    return _showPageCustomizationIcon;
729            }
730    
731            public boolean isShowPageSettingsIcon() {
732                    return _showPageSettingsIcon;
733            }
734    
735            public boolean isShowPortalIcon() {
736                    return _showPortalIcon;
737            }
738    
739            public boolean isShowSignInIcon() {
740                    return _showSignInIcon;
741            }
742    
743            public boolean isShowSignOutIcon() {
744                    return _showSignOutIcon;
745            }
746    
747            public boolean isShowSiteAdministrationIcon() {
748                    return _showSiteAdministrationIcon;
749            }
750    
751            /**
752             * @deprecated As of 6.2.0, replaced by {@link
753             *             #isShowSiteAdministrationIcon()}
754             */
755            public boolean isShowSiteContentIcon() {
756                    return isShowSiteAdministrationIcon();
757            }
758    
759            /**
760             * @deprecated As of 6.2.0, replaced by {@link
761             *             #isShowSiteAdministrationIcon()}
762             */
763            public boolean isShowSiteMapSettingsIcon() {
764                    return _showSiteMapSettingsIcon;
765            }
766    
767            /**
768             * @deprecated As of 6.2.0, replaced by {@link
769             *             #isShowSiteAdministrationIcon()}
770             */
771            public boolean isShowSiteSettingsIcon() {
772                    return _showSiteSettingsIcon;
773            }
774    
775            public boolean isShowStagingIcon() {
776                    return _showStagingIcon;
777            }
778    
779            public boolean isSignedIn() {
780                    return _signedIn;
781            }
782    
783            public boolean isStateExclusive() {
784                    return _stateExclusive;
785            }
786    
787            public boolean isStateMaximized() {
788                    return _stateMaximized;
789            }
790    
791            public boolean isStatePopUp() {
792                    return _statePopUp;
793            }
794    
795            public boolean isThemeCssFastLoad() {
796                    return _themeCssFastLoad;
797            }
798    
799            public boolean isThemeImagesFastLoad() {
800                    return _themeImagesFastLoad;
801            }
802    
803            public boolean isThemeJsBarebone() {
804                    return _themeJsBarebone;
805            }
806    
807            public boolean isThemeJsFastLoad() {
808                    return _themeJsFastLoad;
809            }
810    
811            public boolean isTilesSelectable() {
812                    return _tilesSelectable;
813            }
814    
815            public boolean isWapTheme() {
816                    return _theme.isWapTheme();
817            }
818    
819            public boolean isWidget() {
820                    return _widget;
821            }
822    
823            @Override
824            public ThemeDisplay merge(ThemeDisplay themeDisplay) {
825                    if ((themeDisplay == null) || (themeDisplay == this)) {
826                            return this;
827                    }
828    
829                    _includePortletCssJs = themeDisplay._includePortletCssJs;
830    
831                    return this;
832            }
833    
834            public void setAccount(Account account) {
835                    _account = account;
836            }
837    
838            public void setAddSessionIdToURL(boolean addSessionIdToURL) {
839                    _addSessionIdToURL = addSessionIdToURL;
840            }
841    
842            public void setAjax(boolean ajax) {
843                    _ajax = ajax;
844            }
845    
846            public void setCDNBaseURL(String cdnBase) {
847                    _cdnBaseURL = cdnBase;
848            }
849    
850            public void setCDNDynamicResourcesHost(String cdnDynamicResourcesHost) {
851                    _cdnDynamicResourcesHost = cdnDynamicResourcesHost;
852            }
853    
854            public void setCDNHost(String cdnHost) {
855                    _cdnHost = cdnHost;
856            }
857    
858            public void setCompany(Company company)
859                    throws PortalException, SystemException {
860    
861                    _company = company;
862                    _companyGroupId = company.getGroupId();
863    
864                    setAccount(company.getAccount());
865            }
866    
867            public void setCompanyLogo(String companyLogo) {
868                    _companyLogo = companyLogo;
869            }
870    
871            public void setCompanyLogoHeight(int companyLogoHeight) {
872                    _companyLogoHeight = companyLogoHeight;
873            }
874    
875            public void setCompanyLogoWidth(int companyLogoWidth) {
876                    _companyLogoWidth = companyLogoWidth;
877            }
878    
879            public void setContact(Contact contact) {
880                    _contact = contact;
881            }
882    
883            public void setControlPanelCategory(String controlPanelCategory) {
884                    _controlPanelCategory = controlPanelCategory;
885            }
886    
887            public void setDevice(Device device) {
888                    _device = device;
889            }
890    
891            public void setDoAsGroupId(long doAsGroupId) {
892                    _doAsGroupId = doAsGroupId;
893            }
894    
895            public void setDoAsUserId(String doAsUserId) {
896                    _doAsUserId = doAsUserId;
897            }
898    
899            public void setDoAsUserLanguageId(String doAsUserLanguageId) {
900                    _doAsUserLanguageId = doAsUserLanguageId;
901            }
902    
903            public void setFacebookCanvasPageURL(String facebookCanvasPageURL) {
904                    _facebookCanvasPageURL = facebookCanvasPageURL;
905    
906                    if (Validator.isNotNull(facebookCanvasPageURL)) {
907                            _facebook = true;
908                    }
909            }
910    
911            public void setFreeformLayout(boolean freeformLayout) {
912                    _freeformLayout = freeformLayout;
913            }
914    
915            public void setI18nLanguageId(String i18nLanguageId) {
916                    _i18nLanguageId = i18nLanguageId;
917    
918                    if (Validator.isNotNull(i18nLanguageId)) {
919                            _i18n = true;
920                    }
921                    else {
922                            _i18n = false;
923                    }
924            }
925    
926            public void setI18nPath(String i18nPath) {
927                    _i18nPath = i18nPath;
928    
929                    if (Validator.isNotNull(i18nPath)) {
930                            _i18n = true;
931                    }
932                    else {
933                            _i18n = false;
934                    }
935            }
936    
937            public void setIncludePortletCssJs(boolean includePortletCssJs) {
938                    _includePortletCssJs = includePortletCssJs;
939            }
940    
941            public void setIsolated(boolean isolated) {
942                    _isolated = isolated;
943            }
944    
945            public void setLanguageId(String languageId) {
946                    _languageId = languageId;
947            }
948    
949            public void setLayout(Layout layout) {
950                    _layout = layout;
951            }
952    
953            public void setLayouts(List<Layout> layouts) {
954                    _layouts = layouts;
955            }
956    
957            public void setLayoutSet(LayoutSet layoutSet) {
958                    _layoutSet = layoutSet;
959            }
960    
961            public void setLayoutSetLogo(String layoutSetLogo) {
962                    _layoutSetLogo = layoutSetLogo;
963            }
964    
965            public void setLayoutTypePortlet(LayoutTypePortlet layoutTypePortlet) {
966                    _layoutTypePortlet = layoutTypePortlet;
967            }
968    
969            public void setLifecycle(String lifecycle) {
970                    _lifecycle = lifecycle;
971            }
972    
973            public void setLifecycleAction(boolean lifecycleAction) {
974                    _lifecycleAction = lifecycleAction;
975            }
976    
977            public void setLifecycleEvent(boolean lifecycleEvent) {
978                    _lifecycleEvent = lifecycleEvent;
979            }
980    
981            public void setLifecycleRender(boolean lifecycleRender) {
982                    _lifecycleRender = lifecycleRender;
983            }
984    
985            public void setLifecycleResource(boolean lifecycleResource) {
986                    _lifecycleResource = lifecycleResource;
987            }
988    
989            public void setLocale(Locale locale) {
990                    _locale = locale;
991    
992                    LocaleThreadLocal.setThemeDisplayLocale(locale);
993            }
994    
995            public void setLookAndFeel(Theme theme, ColorScheme colorScheme) {
996                    _theme = theme;
997                    _colorScheme = colorScheme;
998    
999                    if ((theme == null) || (colorScheme == null)) {
1000                            return;
1001                    }
1002    
1003                    String themeStaticResourcePath = theme.getStaticResourcePath();
1004    
1005                    String cdnBaseURL = getCDNBaseURL();
1006    
1007                    setPathColorSchemeImages(
1008                            cdnBaseURL + themeStaticResourcePath +
1009                                    colorScheme.getColorSchemeImagesPath());
1010    
1011                    String dynamicResourcesHost = getCDNDynamicResourcesHost();
1012    
1013                    if (Validator.isNull(dynamicResourcesHost)) {
1014                            String portalURL = getPortalURL();
1015    
1016                            if (getServerName() != null) {
1017                                    try {
1018                                            portalURL = PortalUtil.getPortalURL(getLayout(), this);
1019                                    }
1020                                    catch (Exception e) {
1021                                            _log.error(e, e);
1022                                    }
1023                            }
1024    
1025                            dynamicResourcesHost = portalURL;
1026                    }
1027    
1028                    setPathThemeCss(
1029                            dynamicResourcesHost + themeStaticResourcePath +
1030                                    theme.getCssPath());
1031    
1032                    setPathThemeImages(
1033                            cdnBaseURL + themeStaticResourcePath + theme.getImagesPath());
1034                    setPathThemeJavaScript(
1035                            cdnBaseURL + themeStaticResourcePath +
1036                                    theme.getJavaScriptPath());
1037    
1038                    String rootPath = theme.getRootPath();
1039    
1040                    if (rootPath.equals(StringPool.SLASH)) {
1041                            setPathThemeRoot(themeStaticResourcePath);
1042                    }
1043                    else {
1044                            setPathThemeRoot(themeStaticResourcePath + rootPath);
1045                    }
1046    
1047                    setPathThemeTemplates(
1048                            cdnBaseURL + themeStaticResourcePath + theme.getTemplatesPath());
1049            }
1050    
1051            public void setMDRRuleGroupInstance(
1052                    MDRRuleGroupInstance mdrRuleGroupInstance) {
1053    
1054                    _mdrRuleGroupInstance = mdrRuleGroupInstance;
1055            }
1056    
1057            /**
1058             * @deprecated As of 6.2.0 renamed to {@link #setSiteGroupId(long)}
1059             */
1060            public void setParentGroupId(long parentGroupId) {
1061                    setSiteGroupId(parentGroupId);
1062            }
1063    
1064            public void setPathApplet(String pathApplet) {
1065                    _pathApplet = pathApplet;
1066            }
1067    
1068            public void setPathCms(String pathCms) {
1069                    _pathCms = pathCms;
1070            }
1071    
1072            public void setPathColorSchemeImages(String pathColorSchemeImages) {
1073                    _pathColorSchemeImages = pathColorSchemeImages;
1074            }
1075    
1076            public void setPathContext(String pathContext) {
1077                    _pathContext = pathContext;
1078            }
1079    
1080            public void setPathFlash(String pathFlash) {
1081                    _pathFlash = pathFlash;
1082            }
1083    
1084            public void setPathFriendlyURLPrivateGroup(
1085                    String pathFriendlyURLPrivateGroup) {
1086    
1087                    _pathFriendlyURLPrivateGroup = pathFriendlyURLPrivateGroup;
1088            }
1089    
1090            public void setPathFriendlyURLPrivateUser(
1091                    String pathFriendlyURLPrivateUser) {
1092    
1093                    _pathFriendlyURLPrivateUser = pathFriendlyURLPrivateUser;
1094            }
1095    
1096            public void setPathFriendlyURLPublic(String pathFriendlyURLPublic) {
1097                    _pathFriendlyURLPublic = pathFriendlyURLPublic;
1098            }
1099    
1100            public void setPathImage(String pathImage) {
1101                    if (isFacebook() &&
1102                            !pathImage.startsWith(Http.HTTP_WITH_SLASH) &&
1103                            !pathImage.startsWith(Http.HTTPS_WITH_SLASH)) {
1104    
1105                            pathImage = getPortalURL() + pathImage;
1106                    }
1107    
1108                    _pathImage = pathImage;
1109            }
1110    
1111            public void setPathJavaScript(String pathJavaScript) {
1112                    _pathJavaScript = pathJavaScript;
1113            }
1114    
1115            public void setPathMain(String pathMain) {
1116                    _pathMain = pathMain;
1117            }
1118    
1119            public void setPathSound(String pathSound) {
1120                    _pathSound = pathSound;
1121            }
1122    
1123            public void setPathThemeCss(String pathThemeCss) {
1124                    _pathThemeCss = pathThemeCss;
1125            }
1126    
1127            public void setPathThemeImages(String pathThemeImages) {
1128                    _pathThemeImages = pathThemeImages;
1129            }
1130    
1131            public void setPathThemeJavaScript(String pathThemeJavaScript) {
1132                    _pathThemeJavaScript = pathThemeJavaScript;
1133            }
1134    
1135            public void setPathThemeRoot(String pathThemeRoot) {
1136                    _pathThemeRoot = pathThemeRoot;
1137            }
1138    
1139            public void setPathThemeTemplates(String pathThemeTemplates) {
1140                    _pathThemeTemplates = pathThemeTemplates;
1141            }
1142    
1143            public void setPermissionChecker(PermissionChecker permissionChecker) {
1144                    _permissionChecker = permissionChecker;
1145            }
1146    
1147            public void setPlid(long plid) {
1148                    _plid = plid;
1149            }
1150    
1151            public void setPortalURL(String portalURL) {
1152                    _portalURL = portalURL;
1153            }
1154    
1155            public void setPpid(String ppid) {
1156                    _ppid = ppid;
1157            }
1158    
1159            public void setRealCompanyLogo(String realCompanyLogo) {
1160                    _realCompanyLogo = realCompanyLogo;
1161            }
1162    
1163            public void setRealCompanyLogoHeight(int realCompanyLogoHeight) {
1164                    _realCompanyLogoHeight = realCompanyLogoHeight;
1165            }
1166    
1167            public void setRealCompanyLogoWidth(int realCompanyLogoWidth) {
1168                    _realCompanyLogoWidth = realCompanyLogoWidth;
1169            }
1170    
1171            public void setRealUser(User realUser) {
1172                    _realUser = realUser;
1173            }
1174    
1175            public void setRefererGroupId(long refererGroupId) {
1176                    _refererGroupId = refererGroupId;
1177            }
1178    
1179            public void setRefererPlid(long refererPlid) {
1180                    _refererPlid = refererPlid;
1181            }
1182    
1183            public void setRequest(HttpServletRequest request) {
1184                    _request = request;
1185            }
1186    
1187            public void setScopeGroupId(long scopeGroupId) {
1188                    _scopeGroupId = scopeGroupId;
1189    
1190                    if (_scopeGroupId > 0) {
1191                            try {
1192                                    _scopeGroup = GroupLocalServiceUtil.getGroup(_scopeGroupId);
1193                            }
1194                            catch (Exception e) {
1195                                    _log.error(e, e);
1196                            }
1197                    }
1198            }
1199    
1200            public void setSecure(boolean secure) {
1201                    _secure = secure;
1202            }
1203    
1204            public void setServerName(String serverName) {
1205                    _serverName = serverName;
1206            }
1207    
1208            public void setServerPort(int serverPort) {
1209                    _serverPort = serverPort;
1210            }
1211    
1212            public void setSessionId(String sessionId) {
1213                    _sessionId = sessionId;
1214            }
1215    
1216            public void setShowAddContentIcon(boolean showAddContentIcon) {
1217                    _showAddContentIcon = showAddContentIcon;
1218            }
1219    
1220            public void setShowAddContentIconPermission(
1221                    boolean showAddContentIconPermission) {
1222    
1223                    _showAddContentIconPermission = showAddContentIconPermission;
1224            }
1225    
1226            public void setShowControlPanelIcon(boolean showControlPanelIcon) {
1227                    _showControlPanelIcon = showControlPanelIcon;
1228            }
1229    
1230            public void setShowHomeIcon(boolean showHomeIcon) {
1231                    _showHomeIcon = showHomeIcon;
1232            }
1233    
1234            public void setShowLayoutTemplatesIcon(boolean showLayoutTemplatesIcon) {
1235                    _showLayoutTemplatesIcon = showLayoutTemplatesIcon;
1236            }
1237    
1238            public void setShowManageSiteMembershipsIcon(
1239                    boolean showManageSiteMembershipsIcon) {
1240    
1241                    _showManageSiteMembershipsIcon = showManageSiteMembershipsIcon;
1242            }
1243    
1244            public void setShowMyAccountIcon(boolean showMyAccountIcon) {
1245                    _showMyAccountIcon = showMyAccountIcon;
1246            }
1247    
1248            public void setShowPageCustomizationIcon(
1249                    boolean showPageCustomizationIcon) {
1250    
1251                    _showPageCustomizationIcon = showPageCustomizationIcon;
1252            }
1253    
1254            public void setShowPageSettingsIcon(boolean showPageSettingsIcon) {
1255                    _showPageSettingsIcon = showPageSettingsIcon;
1256            }
1257    
1258            public void setShowPortalIcon(boolean showPortalIcon) {
1259                    _showPortalIcon = showPortalIcon;
1260            }
1261    
1262            public void setShowSignInIcon(boolean showSignInIcon) {
1263                    _showSignInIcon = showSignInIcon;
1264            }
1265    
1266            public void setShowSignOutIcon(boolean showSignOutIcon) {
1267                    _showSignOutIcon = showSignOutIcon;
1268            }
1269    
1270            public void setShowSiteAdministrationIcon(
1271                    boolean showSiteAdministrationIcon) {
1272    
1273                    _showSiteAdministrationIcon = showSiteAdministrationIcon;
1274            }
1275    
1276            /**
1277             * @deprecated As of 6.2.0, replaced by {@link
1278             *             #setShowSiteAdministrationIcon(boolean)}
1279             */
1280            public void setShowSiteContentIcon(boolean showSiteContentIcon) {
1281                    setShowSiteAdministrationIcon(showSiteContentIcon);
1282            }
1283    
1284            public void setShowSiteMapSettingsIcon(boolean showSiteMapSettingsIcon) {
1285                    _showSiteMapSettingsIcon = showSiteMapSettingsIcon;
1286            }
1287    
1288            public void setShowSiteSettingsIcon(boolean showSiteSettingsIcon) {
1289                    _showSiteSettingsIcon = showSiteSettingsIcon;
1290            }
1291    
1292            public void setShowStagingIcon(boolean showStagingIcon) {
1293                    _showStagingIcon = showStagingIcon;
1294            }
1295    
1296            public void setSignedIn(boolean signedIn) {
1297                    _signedIn = signedIn;
1298            }
1299    
1300            public void setSiteDefaultLocale(Locale siteDefaultLocale) {
1301                    _siteDefaultLocale = siteDefaultLocale;
1302    
1303                    LocaleThreadLocal.setSiteDefaultLocale(siteDefaultLocale);
1304            }
1305    
1306            public void setSiteGroupId(long siteGroupId) {
1307                    _siteGroupId = siteGroupId;
1308    
1309                    if (_siteGroupId > 0) {
1310                            try {
1311                                    _siteGroup = GroupLocalServiceUtil.getGroup(_siteGroupId);
1312                            }
1313                            catch (Exception e) {
1314                                    _log.error(e, e);
1315                            }
1316                    }
1317            }
1318    
1319            public void setStateExclusive(boolean stateExclusive) {
1320                    _stateExclusive = stateExclusive;
1321            }
1322    
1323            public void setStateMaximized(boolean stateMaximized) {
1324                    _stateMaximized = stateMaximized;
1325            }
1326    
1327            public void setStatePopUp(boolean statePopUp) {
1328                    _statePopUp = statePopUp;
1329            }
1330    
1331            public void setThemeCssFastLoad(boolean themeCssFastLoad) {
1332                    _themeCssFastLoad = themeCssFastLoad;
1333            }
1334    
1335            public void setThemeImagesFastLoad(boolean themeImagesFastLoad) {
1336                    _themeImagesFastLoad = themeImagesFastLoad;
1337            }
1338    
1339            public void setThemeJsBarebone(boolean themeJsBarebone) {
1340                    _themeJsBarebone = themeJsBarebone;
1341            }
1342    
1343            public void setThemeJsFastLoad(boolean themeJsFastLoad) {
1344                    _themeJsFastLoad = themeJsFastLoad;
1345            }
1346    
1347            public void setTilesContent(String tilesContent) {
1348                    _tilesContent = tilesContent;
1349            }
1350    
1351            public void setTilesSelectable(boolean tilesSelectable) {
1352                    _tilesSelectable = tilesSelectable;
1353            }
1354    
1355            public void setTilesTitle(String tilesTitle) {
1356                    _tilesTitle = tilesTitle;
1357            }
1358    
1359            public void setTimeZone(TimeZone timeZone) {
1360                    _timeZone = timeZone;
1361    
1362                    TimeZoneThreadLocal.setThemeDisplayTimeZone(timeZone);
1363            }
1364    
1365            public void setUnfilteredLayouts(List<Layout> unfilteredLayouts) {
1366                    _unfilteredLayouts = unfilteredLayouts;
1367            }
1368    
1369            public void setURLAddContent(String urlAddContent) {
1370                    _urlAddContent = urlAddContent;
1371            }
1372    
1373            public void setURLControlPanel(String urlControlPanel) {
1374                    _urlControlPanel = urlControlPanel;
1375            }
1376    
1377            public void setURLCurrent(String urlCurrent) {
1378                    _urlCurrent = urlCurrent;
1379            }
1380    
1381            public void setURLHome(String urlHome) {
1382                    _urlHome = urlHome;
1383            }
1384    
1385            public void setURLLayoutTemplates(String urlLayoutTemplates) {
1386                    _urlLayoutTemplates = urlLayoutTemplates;
1387            }
1388    
1389            public void setURLManageSiteMemberships(
1390                    PortletURL urlManageSiteMemberships) {
1391    
1392                    _urlManageSiteMemberships = urlManageSiteMemberships;
1393            }
1394    
1395            public void setURLMyAccount(PortletURL urlMyAccount) {
1396                    _urlMyAccount = urlMyAccount;
1397            }
1398    
1399            public void setURLPageSettings(PortletURL urlPageSettings) {
1400                    _urlPageSettings = urlPageSettings;
1401            }
1402    
1403            public void setURLPortal(String urlPortal) {
1404                    _urlPortal = urlPortal;
1405            }
1406    
1407            public void setURLPublishToLive(PortletURL urlPublishToLive) {
1408                    _urlPublishToLive = urlPublishToLive;
1409            }
1410    
1411            public void setURLSignIn(String urlSignIn) {
1412                    _urlSignIn = urlSignIn;
1413            }
1414    
1415            public void setURLSignOut(String urlSignOut) {
1416                    _urlSignOut = urlSignOut;
1417            }
1418    
1419            public void setURLSiteAdministration(String urlSiteAdministration) {
1420                    _urlSiteAdministration = urlSiteAdministration;
1421            }
1422    
1423            /**
1424             * @deprecated As of 6.2.0, replaced by {@link
1425             *             #setURLSiteAdministration(String)}
1426             */
1427            public void setURLSiteContent(String urlSiteContent) {
1428                    setURLSiteAdministration(urlSiteContent);
1429            }
1430    
1431            public void setURLSiteMapSettings(PortletURL urlSiteMapSettings) {
1432                    _urlSiteMapSettings = urlSiteMapSettings;
1433            }
1434    
1435            public void setURLSiteSettings(PortletURL urlSiteSettings) {
1436                    _urlSiteSettings = urlSiteSettings;
1437            }
1438    
1439            public void setURLUpdateManager(PortletURL urlUpdateManager) {
1440                    _urlUpdateManager = urlUpdateManager;
1441            }
1442    
1443            public void setUser(User user) throws PortalException, SystemException {
1444                    _user = user;
1445    
1446                    setContact(user.getContact());
1447            }
1448    
1449            public void setWidget(boolean widget) {
1450                    _widget = widget;
1451            }
1452    
1453            public String translate(String key) {
1454                    return LanguageUtil.get(getLocale(), key);
1455            }
1456    
1457            public String translate(String pattern, Object argument) {
1458                    return LanguageUtil.format(getLocale(), pattern, argument);
1459            }
1460    
1461            public String translate(String pattern, Object[] arguments) {
1462                    return LanguageUtil.format(getLocale(), pattern, arguments);
1463            }
1464    
1465            private static Log _log = LogFactoryUtil.getLog(ThemeDisplay.class);
1466    
1467            private Account _account;
1468            private boolean _addSessionIdToURL;
1469            private boolean _ajax;
1470            private String _cdnBaseURL;
1471            private String _cdnDynamicResourcesHost = StringPool.BLANK;
1472            private String _cdnHost = StringPool.BLANK;
1473            private ColorScheme _colorScheme;
1474            private Company _company;
1475            private long _companyGroupId;
1476            private String _companyLogo = StringPool.BLANK;
1477            private int _companyLogoHeight;
1478            private int _companyLogoWidth;
1479            private Contact _contact;
1480            private String _controlPanelCategory = StringPool.BLANK;
1481            private User _defaultUser;
1482            private Device _device;
1483            private long _doAsGroupId = 0;
1484            private String _doAsUserId = StringPool.BLANK;
1485            private String _doAsUserLanguageId = StringPool.BLANK;
1486            private boolean _facebook;
1487            private String _facebookCanvasPageURL;
1488            private boolean _freeformLayout;
1489            private boolean _i18n;
1490            private String _i18nLanguageId;
1491            private String _i18nPath;
1492            private boolean _includePortletCssJs;
1493            private boolean _isolated;
1494            private String _languageId;
1495            private Layout _layout;
1496            private List<Layout> _layouts;
1497            private LayoutSet _layoutSet;
1498            private String _layoutSetLogo = StringPool.BLANK;
1499            private LayoutTypePortlet _layoutTypePortlet;
1500            private String _lifecycle;
1501            private boolean _lifecycleAction;
1502            private boolean _lifecycleEvent;
1503            private boolean _lifecycleRender;
1504            private boolean _lifecycleResource;
1505            private Locale _locale;
1506            private MDRRuleGroupInstance _mdrRuleGroupInstance;
1507            private String _pathApplet = StringPool.BLANK;
1508            private String _pathCms = StringPool.BLANK;
1509            private String _pathColorSchemeImages = StringPool.BLANK;
1510            private String _pathContext = StringPool.BLANK;
1511            private String _pathFlash = StringPool.BLANK;
1512            private String _pathFriendlyURLPrivateGroup = StringPool.BLANK;
1513            private String _pathFriendlyURLPrivateUser = StringPool.BLANK;
1514            private String _pathFriendlyURLPublic = StringPool.BLANK;
1515            private String _pathImage = StringPool.BLANK;
1516            private String _pathJavaScript = StringPool.BLANK;
1517            private String _pathMain = StringPool.BLANK;
1518            private String _pathSound = StringPool.BLANK;
1519            private String _pathThemeCss = StringPool.BLANK;
1520            private String _pathThemeImages = StringPool.BLANK;
1521            private String _pathThemeJavaScript = StringPool.BLANK;
1522            private String _pathThemeRoot = StringPool.BLANK;
1523            private String _pathThemeTemplates = StringPool.BLANK;
1524            private transient PermissionChecker _permissionChecker;
1525            private long _plid;
1526            private String _portalURL = StringPool.BLANK;
1527            private PortletDisplay _portletDisplay = new PortletDisplay();
1528            private String _ppid = StringPool.BLANK;
1529            private String _realCompanyLogo = StringPool.BLANK;
1530            private int _realCompanyLogoHeight;
1531            private int _realCompanyLogoWidth;
1532            private User _realUser;
1533            private long _refererGroupId;
1534            private long _refererPlid;
1535            private transient HttpServletRequest _request;
1536            private Group _scopeGroup;
1537            private long _scopeGroupId;
1538            private boolean _secure;
1539            private String _serverName;
1540            private int _serverPort;
1541            private String _sessionId = StringPool.BLANK;
1542            private boolean _showAddContentIcon;
1543            private boolean _showAddContentIconPermission;
1544            private boolean _showControlPanelIcon;
1545            private boolean _showHomeIcon;
1546            private boolean _showLayoutTemplatesIcon;
1547            private boolean _showManageSiteMembershipsIcon;
1548            private boolean _showMyAccountIcon;
1549            private boolean _showPageCustomizationIcon;
1550            private boolean _showPageSettingsIcon;
1551            private boolean _showPortalIcon;
1552            private boolean _showSignInIcon;
1553            private boolean _showSignOutIcon;
1554            private boolean _showSiteAdministrationIcon;
1555            private boolean _showSiteMapSettingsIcon;
1556            private boolean _showSiteSettingsIcon;
1557            private boolean _showStagingIcon;
1558            private boolean _signedIn;
1559            private Locale _siteDefaultLocale;
1560            private Group _siteGroup;
1561            private long _siteGroupId;
1562            private boolean _stateExclusive;
1563            private boolean _stateMaximized;
1564            private boolean _statePopUp;
1565            private Theme _theme;
1566            private boolean _themeCssFastLoad;
1567            private boolean _themeImagesFastLoad;
1568            private boolean _themeJsBarebone;
1569            private boolean _themeJsFastLoad;
1570            private String _tilesContent = StringPool.BLANK;
1571            private boolean _tilesSelectable;
1572            private String _tilesTitle = StringPool.BLANK;
1573            private TimeZone _timeZone;
1574            private List<Layout> _unfilteredLayouts;
1575            private String _urlAddContent = StringPool.BLANK;
1576            private String _urlControlPanel = StringPool.BLANK;
1577            private String _urlCurrent = StringPool.BLANK;
1578            private String _urlHome = StringPool.BLANK;
1579            private String _urlLayoutTemplates = StringPool.BLANK;
1580            private transient PortletURL _urlManageSiteMemberships = null;
1581            private transient PortletURL _urlMyAccount = null;
1582            private transient PortletURL _urlPageSettings = null;
1583            private String _urlPortal = StringPool.BLANK;
1584            private transient PortletURL _urlPublishToLive = null;
1585            private String _urlSignIn = StringPool.BLANK;
1586            private String _urlSignOut = StringPool.BLANK;
1587            private String _urlSiteAdministration = StringPool.BLANK;
1588            private transient PortletURL _urlSiteMapSettings = null;
1589            private transient PortletURL _urlSiteSettings = null;
1590            private transient PortletURL _urlUpdateManager = null;
1591            private User _user;
1592            private boolean _widget;
1593    
1594    }