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