001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.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 getPortalDomain() {
346                    return _portalDomain;
347            }
348    
349            public String getPortalURL() {
350                    return _portalURL;
351            }
352    
353            public PortletDisplay getPortletDisplay() {
354                    return _portletDisplay;
355            }
356    
357            /**
358             * @deprecated As of 6.2.0, replaced by {@link #getScopeGroupId}
359             */
360            public long getPortletGroupId() {
361                    return getScopeGroupId();
362            }
363    
364            public String getPpid() {
365                    return _ppid;
366            }
367    
368            public String getRealCompanyLogo() {
369                    return _realCompanyLogo;
370            }
371    
372            public int getRealCompanyLogoHeight() {
373                    return _realCompanyLogoHeight;
374            }
375    
376            public int getRealCompanyLogoWidth() {
377                    return _realCompanyLogoWidth;
378            }
379    
380            public User getRealUser() {
381                    return _realUser;
382            }
383    
384            public long getRealUserId() {
385                    return _realUser.getUserId();
386            }
387    
388            public long getRefererGroupId() {
389                    return _refererGroupId;
390            }
391    
392            public long getRefererPlid() {
393                    return _refererPlid;
394            }
395    
396            public HttpServletRequest getRequest() {
397                    return _request;
398            }
399    
400            public Group getScopeGroup() {
401                    return _scopeGroup;
402            }
403    
404            public long getScopeGroupId() {
405                    return _scopeGroupId;
406            }
407    
408            /**
409             * @deprecated As of 6.2.0 renamed to {@link #getSiteGroupIdOrLiveGroupId}
410             */
411            public long getScopeGroupIdOrLiveGroupId()
412                    throws PortalException, SystemException {
413    
414                    return getSiteGroupIdOrLiveGroupId();
415            }
416    
417            public String getScopeGroupName() throws PortalException, SystemException {
418                    if (_scopeGroup == null) {
419                            return StringPool.BLANK;
420                    }
421    
422                    return _scopeGroup.getDescriptiveName();
423            }
424    
425            public Layout getScopeLayout() throws PortalException, SystemException {
426                    if (_layout.hasScopeGroup()) {
427                            return _layout;
428                    }
429                    else if (_scopeGroup.isLayout()) {
430                            return LayoutLocalServiceUtil.getLayout(_scopeGroup.getClassPK());
431                    }
432                    else {
433                            return null;
434                    }
435            }
436    
437            public String getServerName() {
438                    return _serverName;
439            }
440    
441            public int getServerPort() {
442                    return _serverPort;
443            }
444    
445            public String getSessionId() {
446                    return _sessionId;
447            }
448    
449            public Locale getSiteDefaultLocale() {
450                    return _siteDefaultLocale;
451            }
452    
453            public Group getSiteGroup() {
454                    return _siteGroup;
455            }
456    
457            public long getSiteGroupId() {
458                    return _siteGroupId;
459            }
460    
461            public long getSiteGroupIdOrLiveGroupId()
462                    throws PortalException, SystemException {
463    
464                    return StagingUtil.getLiveGroupId(_siteGroupId);
465            }
466    
467            public String getSiteGroupName() throws PortalException, SystemException {
468                    if (_siteGroup == null) {
469                            return StringPool.BLANK;
470                    }
471    
472                    return _siteGroup.getDescriptiveName();
473            }
474    
475            public Theme getTheme() {
476                    return _theme;
477            }
478    
479            public String getThemeId() {
480                    return _theme.getThemeId();
481            }
482    
483            public String getThemeSetting(String key) {
484                    Theme theme = getTheme();
485    
486                    String device = theme.getDevice();
487    
488                    Layout layout = getLayout();
489    
490                    return layout.getThemeSetting(key, device);
491            }
492    
493            public Properties getThemeSettings() {
494                    Theme theme = getTheme();
495    
496                    Properties properties = new Properties();
497    
498                    Map<String, ThemeSetting> themeSettings = theme.getSettings();
499    
500                    for (String key : themeSettings.keySet()) {
501                            ThemeSetting themeSetting = themeSettings.get(key);
502    
503                            String value = null;
504    
505                            if (themeSetting.isConfigurable()) {
506                                    value = getThemeSetting(key);
507                            }
508                            else {
509                                    value = themeSetting.getValue();
510                            }
511    
512                            if (value != null) {
513                                    properties.put(key, value);
514                            }
515                    }
516    
517                    return properties;
518            }
519    
520            public String getTilesContent() {
521                    return _tilesContent;
522            }
523    
524            public String getTilesTitle() {
525                    return _tilesTitle;
526            }
527    
528            public TimeZone getTimeZone() {
529                    return _timeZone;
530            }
531    
532            public List<Layout> getUnfilteredLayouts() {
533                    return _unfilteredLayouts;
534            }
535    
536            public String getURLAddContent() {
537                    return _urlAddContent;
538            }
539    
540            public String getURLControlPanel() {
541                    return _urlControlPanel;
542            }
543    
544            public String getURLCurrent() {
545                    return _urlCurrent;
546            }
547    
548            public String getURLHome() {
549                    return _urlHome;
550            }
551    
552            public String getURLLayoutTemplates() {
553                    if (Validator.isNull(_urlLayoutTemplates)) {
554                            return _urlPageSettings + "#layout";
555                    }
556    
557                    return _urlLayoutTemplates;
558            }
559    
560            /**
561             * @deprecated As of 6.2.0, replaced by {@link #getURLSiteAdministration()}
562             */
563            public PortletURL getURLManageSiteMemberships() {
564                    return _urlManageSiteMemberships;
565            }
566    
567            public PortletURL getURLMyAccount() {
568                    return _urlMyAccount;
569            }
570    
571            public PortletURL getURLPageSettings() {
572                    return _urlPageSettings;
573            }
574    
575            public String getURLPortal() {
576                    return _urlPortal;
577            }
578    
579            public PortletURL getURLPublishToLive() {
580                    return _urlPublishToLive;
581            }
582    
583            public String getURLSignIn() {
584                    return _urlSignIn;
585            }
586    
587            public String getURLSignOut() {
588                    return _urlSignOut;
589            }
590    
591            public String getURLSiteAdministration() {
592                    return _urlSiteAdministration;
593            }
594    
595            /**
596             * @deprecated As of 6.2.0, replaced by {@link #getURLSiteAdministration()}
597             */
598            public String getURLSiteContent() {
599                    return getURLSiteAdministration();
600            }
601    
602            /**
603             * @deprecated As of 6.2.0, replaced by {@link
604             *             #isShowSiteAdministrationIcon()}
605             */
606            public PortletURL getURLSiteMapSettings() {
607                    return _urlSiteMapSettings;
608            }
609    
610            /**
611             * @deprecated As of 6.2.0, replaced by {@link #getURLSiteAdministration()}
612             */
613            public PortletURL getURLSiteSettings() {
614                    return _urlSiteSettings;
615            }
616    
617            public PortletURL getURLUpdateManager() {
618                    return _urlUpdateManager;
619            }
620    
621            public User getUser() {
622                    return _user;
623            }
624    
625            public long getUserId() {
626                    return _user.getUserId();
627            }
628    
629            public boolean isAddSessionIdToURL() {
630                    return _addSessionIdToURL;
631            }
632    
633            public boolean isAjax() {
634                    return _ajax;
635            }
636    
637            public boolean isFacebook() {
638                    return _facebook;
639            }
640    
641            public boolean isFreeformLayout() {
642                    return _freeformLayout;
643            }
644    
645            public boolean isI18n() {
646                    return _i18n;
647            }
648    
649            public boolean isImpersonated() {
650                    if (getUserId() == getRealUserId()) {
651                            return false;
652                    }
653    
654                    return true;
655            }
656    
657            public boolean isIncludedJs(String js) {
658                    String path = getPathJavaScript();
659    
660                    if (isIncludePortletCssJs() &&
661                            js.startsWith(path + "/liferay/portlet_css.js")) {
662    
663                            return true;
664                    }
665    
666                    return false;
667            }
668    
669            public boolean isIncludePortletCssJs() {
670                    return _includePortletCssJs;
671            }
672    
673            public boolean isIsolated() {
674                    return _isolated;
675            }
676    
677            public boolean isLifecycleAction() {
678                    return _lifecycleAction;
679            }
680    
681            public boolean isLifecycleEvent() {
682                    return _lifecycleEvent;
683            }
684    
685            public boolean isLifecycleRender() {
686                    return _lifecycleRender;
687            }
688    
689            public boolean isLifecycleResource() {
690                    return _lifecycleResource;
691            }
692    
693            public boolean isSecure() {
694                    return _secure;
695            }
696    
697            public boolean isShowAddContentIcon() {
698                    return _showAddContentIcon;
699            }
700    
701            public boolean isShowAddContentIconPermission() {
702                    return _showAddContentIconPermission;
703            }
704    
705            public boolean isShowControlPanelIcon() {
706                    return _showControlPanelIcon;
707            }
708    
709            public boolean isShowHomeIcon() {
710                    return _showHomeIcon;
711            }
712    
713            public boolean isShowLayoutTemplatesIcon() {
714                    return _showLayoutTemplatesIcon;
715            }
716    
717            /**
718             * @deprecated As of 6.2.0, replaced by {@link
719             *             #isShowSiteAdministrationIcon()}
720             */
721            public boolean isShowManageSiteMembershipsIcon() {
722                    return _showManageSiteMembershipsIcon;
723            }
724    
725            public boolean isShowMyAccountIcon() {
726                    return _showMyAccountIcon;
727            }
728    
729            public boolean isShowPageCustomizationIcon() {
730                    return _showPageCustomizationIcon;
731            }
732    
733            public boolean isShowPageSettingsIcon() {
734                    return _showPageSettingsIcon;
735            }
736    
737            public boolean isShowPortalIcon() {
738                    return _showPortalIcon;
739            }
740    
741            public boolean isShowSignInIcon() {
742                    return _showSignInIcon;
743            }
744    
745            public boolean isShowSignOutIcon() {
746                    return _showSignOutIcon;
747            }
748    
749            public boolean isShowSiteAdministrationIcon() {
750                    return _showSiteAdministrationIcon;
751            }
752    
753            /**
754             * @deprecated As of 6.2.0, replaced by {@link
755             *             #isShowSiteAdministrationIcon()}
756             */
757            public boolean isShowSiteContentIcon() {
758                    return isShowSiteAdministrationIcon();
759            }
760    
761            /**
762             * @deprecated As of 6.2.0, replaced by {@link
763             *             #isShowSiteAdministrationIcon()}
764             */
765            public boolean isShowSiteMapSettingsIcon() {
766                    return _showSiteMapSettingsIcon;
767            }
768    
769            /**
770             * @deprecated As of 6.2.0, replaced by {@link
771             *             #isShowSiteAdministrationIcon()}
772             */
773            public boolean isShowSiteSettingsIcon() {
774                    return _showSiteSettingsIcon;
775            }
776    
777            public boolean isShowStagingIcon() {
778                    return _showStagingIcon;
779            }
780    
781            public boolean isSignedIn() {
782                    return _signedIn;
783            }
784    
785            public boolean isStateExclusive() {
786                    return _stateExclusive;
787            }
788    
789            public boolean isStateMaximized() {
790                    return _stateMaximized;
791            }
792    
793            public boolean isStatePopUp() {
794                    return _statePopUp;
795            }
796    
797            public boolean isThemeCssFastLoad() {
798                    return _themeCssFastLoad;
799            }
800    
801            public boolean isThemeImagesFastLoad() {
802                    return _themeImagesFastLoad;
803            }
804    
805            public boolean isThemeJsBarebone() {
806                    return _themeJsBarebone;
807            }
808    
809            public boolean isThemeJsFastLoad() {
810                    return _themeJsFastLoad;
811            }
812    
813            public boolean isTilesSelectable() {
814                    return _tilesSelectable;
815            }
816    
817            public boolean isWapTheme() {
818                    return _theme.isWapTheme();
819            }
820    
821            public boolean isWidget() {
822                    return _widget;
823            }
824    
825            @Override
826            public ThemeDisplay merge(ThemeDisplay themeDisplay) {
827                    if ((themeDisplay == null) || (themeDisplay == this)) {
828                            return this;
829                    }
830    
831                    _includePortletCssJs = themeDisplay._includePortletCssJs;
832    
833                    return this;
834            }
835    
836            public void setAccount(Account account) {
837                    _account = account;
838            }
839    
840            public void setAddSessionIdToURL(boolean addSessionIdToURL) {
841                    _addSessionIdToURL = addSessionIdToURL;
842            }
843    
844            public void setAjax(boolean ajax) {
845                    _ajax = ajax;
846            }
847    
848            public void setCDNBaseURL(String cdnBase) {
849                    _cdnBaseURL = cdnBase;
850            }
851    
852            public void setCDNDynamicResourcesHost(String cdnDynamicResourcesHost) {
853                    _cdnDynamicResourcesHost = cdnDynamicResourcesHost;
854            }
855    
856            public void setCDNHost(String cdnHost) {
857                    _cdnHost = cdnHost;
858            }
859    
860            public void setCompany(Company company)
861                    throws PortalException, SystemException {
862    
863                    _company = company;
864                    _companyGroupId = company.getGroupId();
865    
866                    setAccount(company.getAccount());
867            }
868    
869            public void setCompanyLogo(String companyLogo) {
870                    _companyLogo = companyLogo;
871            }
872    
873            public void setCompanyLogoHeight(int companyLogoHeight) {
874                    _companyLogoHeight = companyLogoHeight;
875            }
876    
877            public void setCompanyLogoWidth(int companyLogoWidth) {
878                    _companyLogoWidth = companyLogoWidth;
879            }
880    
881            public void setContact(Contact contact) {
882                    _contact = contact;
883            }
884    
885            public void setControlPanelCategory(String controlPanelCategory) {
886                    _controlPanelCategory = controlPanelCategory;
887            }
888    
889            public void setDevice(Device device) {
890                    _device = device;
891            }
892    
893            public void setDoAsGroupId(long doAsGroupId) {
894                    _doAsGroupId = doAsGroupId;
895            }
896    
897            public void setDoAsUserId(String doAsUserId) {
898                    _doAsUserId = doAsUserId;
899            }
900    
901            public void setDoAsUserLanguageId(String doAsUserLanguageId) {
902                    _doAsUserLanguageId = doAsUserLanguageId;
903            }
904    
905            public void setFacebookCanvasPageURL(String facebookCanvasPageURL) {
906                    _facebookCanvasPageURL = facebookCanvasPageURL;
907    
908                    if (Validator.isNotNull(facebookCanvasPageURL)) {
909                            _facebook = true;
910                    }
911            }
912    
913            public void setFreeformLayout(boolean freeformLayout) {
914                    _freeformLayout = freeformLayout;
915            }
916    
917            public void setI18nLanguageId(String i18nLanguageId) {
918                    _i18nLanguageId = i18nLanguageId;
919    
920                    if (Validator.isNotNull(i18nLanguageId)) {
921                            _i18n = true;
922                    }
923                    else {
924                            _i18n = false;
925                    }
926            }
927    
928            public void setI18nPath(String i18nPath) {
929                    _i18nPath = i18nPath;
930    
931                    if (Validator.isNotNull(i18nPath)) {
932                            _i18n = true;
933                    }
934                    else {
935                            _i18n = false;
936                    }
937            }
938    
939            public void setIncludePortletCssJs(boolean includePortletCssJs) {
940                    _includePortletCssJs = includePortletCssJs;
941            }
942    
943            public void setIsolated(boolean isolated) {
944                    _isolated = isolated;
945            }
946    
947            public void setLanguageId(String languageId) {
948                    _languageId = languageId;
949            }
950    
951            public void setLayout(Layout layout) {
952                    _layout = layout;
953            }
954    
955            public void setLayouts(List<Layout> layouts) {
956                    _layouts = layouts;
957            }
958    
959            public void setLayoutSet(LayoutSet layoutSet) {
960                    _layoutSet = layoutSet;
961            }
962    
963            public void setLayoutSetLogo(String layoutSetLogo) {
964                    _layoutSetLogo = layoutSetLogo;
965            }
966    
967            public void setLayoutTypePortlet(LayoutTypePortlet layoutTypePortlet) {
968                    _layoutTypePortlet = layoutTypePortlet;
969            }
970    
971            public void setLifecycle(String lifecycle) {
972                    _lifecycle = lifecycle;
973            }
974    
975            public void setLifecycleAction(boolean lifecycleAction) {
976                    _lifecycleAction = lifecycleAction;
977            }
978    
979            public void setLifecycleEvent(boolean lifecycleEvent) {
980                    _lifecycleEvent = lifecycleEvent;
981            }
982    
983            public void setLifecycleRender(boolean lifecycleRender) {
984                    _lifecycleRender = lifecycleRender;
985            }
986    
987            public void setLifecycleResource(boolean lifecycleResource) {
988                    _lifecycleResource = lifecycleResource;
989            }
990    
991            public void setLocale(Locale locale) {
992                    _locale = locale;
993    
994                    LocaleThreadLocal.setThemeDisplayLocale(locale);
995            }
996    
997            public void setLookAndFeel(Theme theme, ColorScheme colorScheme) {
998                    _theme = theme;
999                    _colorScheme = colorScheme;
1000    
1001                    if ((theme == null) || (colorScheme == null)) {
1002                            return;
1003                    }
1004    
1005                    String themeStaticResourcePath = theme.getStaticResourcePath();
1006    
1007                    String cdnBaseURL = getCDNBaseURL();
1008    
1009                    setPathColorSchemeImages(
1010                            cdnBaseURL + themeStaticResourcePath +
1011                                    colorScheme.getColorSchemeImagesPath());
1012    
1013                    String dynamicResourcesHost = getCDNDynamicResourcesHost();
1014    
1015                    if (Validator.isNull(dynamicResourcesHost)) {
1016                            String portalURL = getPortalURL();
1017    
1018                            try {
1019                                    portalURL = PortalUtil.getPortalURL(getLayout(), this);
1020                            }
1021                            catch (Exception e) {
1022                                    _log.error(e, e);
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 setPortalDomain(String portalDomain) {
1152                    _portalDomain = portalDomain;
1153            }
1154    
1155            public void setPortalURL(String portalURL) {
1156                    _portalURL = portalURL;
1157            }
1158    
1159            public void setPpid(String ppid) {
1160                    _ppid = ppid;
1161            }
1162    
1163            public void setRealCompanyLogo(String realCompanyLogo) {
1164                    _realCompanyLogo = realCompanyLogo;
1165            }
1166    
1167            public void setRealCompanyLogoHeight(int realCompanyLogoHeight) {
1168                    _realCompanyLogoHeight = realCompanyLogoHeight;
1169            }
1170    
1171            public void setRealCompanyLogoWidth(int realCompanyLogoWidth) {
1172                    _realCompanyLogoWidth = realCompanyLogoWidth;
1173            }
1174    
1175            public void setRealUser(User realUser) {
1176                    _realUser = realUser;
1177            }
1178    
1179            public void setRefererGroupId(long refererGroupId) {
1180                    _refererGroupId = refererGroupId;
1181            }
1182    
1183            public void setRefererPlid(long refererPlid) {
1184                    _refererPlid = refererPlid;
1185            }
1186    
1187            public void setRequest(HttpServletRequest request) {
1188                    _request = request;
1189            }
1190    
1191            public void setScopeGroupId(long scopeGroupId) {
1192                    _scopeGroupId = scopeGroupId;
1193    
1194                    if (_scopeGroupId > 0) {
1195                            try {
1196                                    _scopeGroup = GroupLocalServiceUtil.getGroup(_scopeGroupId);
1197                            }
1198                            catch (Exception e) {
1199                                    _log.error(e, e);
1200                            }
1201                    }
1202            }
1203    
1204            public void setSecure(boolean secure) {
1205                    _secure = secure;
1206            }
1207    
1208            public void setServerName(String serverName) {
1209                    _serverName = serverName;
1210            }
1211    
1212            public void setServerPort(int serverPort) {
1213                    _serverPort = serverPort;
1214            }
1215    
1216            public void setSessionId(String sessionId) {
1217                    _sessionId = sessionId;
1218            }
1219    
1220            public void setShowAddContentIcon(boolean showAddContentIcon) {
1221                    _showAddContentIcon = showAddContentIcon;
1222            }
1223    
1224            public void setShowAddContentIconPermission(
1225                    boolean showAddContentIconPermission) {
1226    
1227                    _showAddContentIconPermission = showAddContentIconPermission;
1228            }
1229    
1230            public void setShowControlPanelIcon(boolean showControlPanelIcon) {
1231                    _showControlPanelIcon = showControlPanelIcon;
1232            }
1233    
1234            public void setShowHomeIcon(boolean showHomeIcon) {
1235                    _showHomeIcon = showHomeIcon;
1236            }
1237    
1238            public void setShowLayoutTemplatesIcon(boolean showLayoutTemplatesIcon) {
1239                    _showLayoutTemplatesIcon = showLayoutTemplatesIcon;
1240            }
1241    
1242            public void setShowManageSiteMembershipsIcon(
1243                    boolean showManageSiteMembershipsIcon) {
1244    
1245                    _showManageSiteMembershipsIcon = showManageSiteMembershipsIcon;
1246            }
1247    
1248            public void setShowMyAccountIcon(boolean showMyAccountIcon) {
1249                    _showMyAccountIcon = showMyAccountIcon;
1250            }
1251    
1252            public void setShowPageCustomizationIcon(
1253                    boolean showPageCustomizationIcon) {
1254    
1255                    _showPageCustomizationIcon = showPageCustomizationIcon;
1256            }
1257    
1258            public void setShowPageSettingsIcon(boolean showPageSettingsIcon) {
1259                    _showPageSettingsIcon = showPageSettingsIcon;
1260            }
1261    
1262            public void setShowPortalIcon(boolean showPortalIcon) {
1263                    _showPortalIcon = showPortalIcon;
1264            }
1265    
1266            public void setShowSignInIcon(boolean showSignInIcon) {
1267                    _showSignInIcon = showSignInIcon;
1268            }
1269    
1270            public void setShowSignOutIcon(boolean showSignOutIcon) {
1271                    _showSignOutIcon = showSignOutIcon;
1272            }
1273    
1274            public void setShowSiteAdministrationIcon(
1275                    boolean showSiteAdministrationIcon) {
1276    
1277                    _showSiteAdministrationIcon = showSiteAdministrationIcon;
1278            }
1279    
1280            /**
1281             * @deprecated As of 6.2.0, replaced by {@link
1282             *             #setShowSiteAdministrationIcon(boolean)}
1283             */
1284            public void setShowSiteContentIcon(boolean showSiteContentIcon) {
1285                    setShowSiteAdministrationIcon(showSiteContentIcon);
1286            }
1287    
1288            public void setShowSiteMapSettingsIcon(boolean showSiteMapSettingsIcon) {
1289                    _showSiteMapSettingsIcon = showSiteMapSettingsIcon;
1290            }
1291    
1292            public void setShowSiteSettingsIcon(boolean showSiteSettingsIcon) {
1293                    _showSiteSettingsIcon = showSiteSettingsIcon;
1294            }
1295    
1296            public void setShowStagingIcon(boolean showStagingIcon) {
1297                    _showStagingIcon = showStagingIcon;
1298            }
1299    
1300            public void setSignedIn(boolean signedIn) {
1301                    _signedIn = signedIn;
1302            }
1303    
1304            public void setSiteDefaultLocale(Locale siteDefaultLocale) {
1305                    _siteDefaultLocale = siteDefaultLocale;
1306    
1307                    LocaleThreadLocal.setSiteDefaultLocale(siteDefaultLocale);
1308            }
1309    
1310            public void setSiteGroupId(long siteGroupId) {
1311                    _siteGroupId = siteGroupId;
1312    
1313                    if (_siteGroupId > 0) {
1314                            try {
1315                                    _siteGroup = GroupLocalServiceUtil.getGroup(_siteGroupId);
1316                            }
1317                            catch (Exception e) {
1318                                    _log.error(e, e);
1319                            }
1320                    }
1321            }
1322    
1323            public void setStateExclusive(boolean stateExclusive) {
1324                    _stateExclusive = stateExclusive;
1325            }
1326    
1327            public void setStateMaximized(boolean stateMaximized) {
1328                    _stateMaximized = stateMaximized;
1329            }
1330    
1331            public void setStatePopUp(boolean statePopUp) {
1332                    _statePopUp = statePopUp;
1333            }
1334    
1335            public void setThemeCssFastLoad(boolean themeCssFastLoad) {
1336                    _themeCssFastLoad = themeCssFastLoad;
1337            }
1338    
1339            public void setThemeImagesFastLoad(boolean themeImagesFastLoad) {
1340                    _themeImagesFastLoad = themeImagesFastLoad;
1341            }
1342    
1343            public void setThemeJsBarebone(boolean themeJsBarebone) {
1344                    _themeJsBarebone = themeJsBarebone;
1345            }
1346    
1347            public void setThemeJsFastLoad(boolean themeJsFastLoad) {
1348                    _themeJsFastLoad = themeJsFastLoad;
1349            }
1350    
1351            public void setTilesContent(String tilesContent) {
1352                    _tilesContent = tilesContent;
1353            }
1354    
1355            public void setTilesSelectable(boolean tilesSelectable) {
1356                    _tilesSelectable = tilesSelectable;
1357            }
1358    
1359            public void setTilesTitle(String tilesTitle) {
1360                    _tilesTitle = tilesTitle;
1361            }
1362    
1363            public void setTimeZone(TimeZone timeZone) {
1364                    _timeZone = timeZone;
1365    
1366                    TimeZoneThreadLocal.setThemeDisplayTimeZone(timeZone);
1367            }
1368    
1369            public void setUnfilteredLayouts(List<Layout> unfilteredLayouts) {
1370                    _unfilteredLayouts = unfilteredLayouts;
1371            }
1372    
1373            public void setURLAddContent(String urlAddContent) {
1374                    _urlAddContent = urlAddContent;
1375            }
1376    
1377            public void setURLControlPanel(String urlControlPanel) {
1378                    _urlControlPanel = urlControlPanel;
1379            }
1380    
1381            public void setURLCurrent(String urlCurrent) {
1382                    _urlCurrent = urlCurrent;
1383            }
1384    
1385            public void setURLHome(String urlHome) {
1386                    _urlHome = urlHome;
1387            }
1388    
1389            public void setURLLayoutTemplates(String urlLayoutTemplates) {
1390                    _urlLayoutTemplates = urlLayoutTemplates;
1391            }
1392    
1393            public void setURLManageSiteMemberships(
1394                    PortletURL urlManageSiteMemberships) {
1395    
1396                    _urlManageSiteMemberships = urlManageSiteMemberships;
1397            }
1398    
1399            public void setURLMyAccount(PortletURL urlMyAccount) {
1400                    _urlMyAccount = urlMyAccount;
1401            }
1402    
1403            public void setURLPageSettings(PortletURL urlPageSettings) {
1404                    _urlPageSettings = urlPageSettings;
1405            }
1406    
1407            public void setURLPortal(String urlPortal) {
1408                    _urlPortal = urlPortal;
1409            }
1410    
1411            public void setURLPublishToLive(PortletURL urlPublishToLive) {
1412                    _urlPublishToLive = urlPublishToLive;
1413            }
1414    
1415            public void setURLSignIn(String urlSignIn) {
1416                    _urlSignIn = urlSignIn;
1417            }
1418    
1419            public void setURLSignOut(String urlSignOut) {
1420                    _urlSignOut = urlSignOut;
1421            }
1422    
1423            public void setURLSiteAdministration(String urlSiteAdministration) {
1424                    _urlSiteAdministration = urlSiteAdministration;
1425            }
1426    
1427            /**
1428             * @deprecated As of 6.2.0, replaced by {@link
1429             *             #setURLSiteAdministration(String)}
1430             */
1431            public void setURLSiteContent(String urlSiteContent) {
1432                    setURLSiteAdministration(urlSiteContent);
1433            }
1434    
1435            public void setURLSiteMapSettings(PortletURL urlSiteMapSettings) {
1436                    _urlSiteMapSettings = urlSiteMapSettings;
1437            }
1438    
1439            public void setURLSiteSettings(PortletURL urlSiteSettings) {
1440                    _urlSiteSettings = urlSiteSettings;
1441            }
1442    
1443            public void setURLUpdateManager(PortletURL urlUpdateManager) {
1444                    _urlUpdateManager = urlUpdateManager;
1445            }
1446    
1447            public void setUser(User user) throws PortalException, SystemException {
1448                    _user = user;
1449    
1450                    setContact(user.getContact());
1451            }
1452    
1453            public void setWidget(boolean widget) {
1454                    _widget = widget;
1455            }
1456    
1457            public String translate(String key) {
1458                    return LanguageUtil.get(getLocale(), key);
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 _portalDomain = StringPool.BLANK;
1527            private String _portalURL = StringPool.BLANK;
1528            private PortletDisplay _portletDisplay = new PortletDisplay();
1529            private String _ppid = StringPool.BLANK;
1530            private String _realCompanyLogo = StringPool.BLANK;
1531            private int _realCompanyLogoHeight;
1532            private int _realCompanyLogoWidth;
1533            private User _realUser;
1534            private long _refererGroupId;
1535            private long _refererPlid;
1536            private transient HttpServletRequest _request;
1537            private Group _scopeGroup;
1538            private long _scopeGroupId;
1539            private boolean _secure;
1540            private String _serverName;
1541            private int _serverPort;
1542            private String _sessionId = StringPool.BLANK;
1543            private boolean _showAddContentIcon;
1544            private boolean _showAddContentIconPermission;
1545            private boolean _showControlPanelIcon;
1546            private boolean _showHomeIcon;
1547            private boolean _showLayoutTemplatesIcon;
1548            private boolean _showManageSiteMembershipsIcon;
1549            private boolean _showMyAccountIcon;
1550            private boolean _showPageCustomizationIcon;
1551            private boolean _showPageSettingsIcon;
1552            private boolean _showPortalIcon;
1553            private boolean _showSignInIcon;
1554            private boolean _showSignOutIcon;
1555            private boolean _showSiteAdministrationIcon;
1556            private boolean _showSiteMapSettingsIcon;
1557            private boolean _showSiteSettingsIcon;
1558            private boolean _showStagingIcon;
1559            private boolean _signedIn;
1560            private Locale _siteDefaultLocale;
1561            private Group _siteGroup;
1562            private long _siteGroupId;
1563            private boolean _stateExclusive;
1564            private boolean _stateMaximized;
1565            private boolean _statePopUp;
1566            private Theme _theme;
1567            private boolean _themeCssFastLoad;
1568            private boolean _themeImagesFastLoad;
1569            private boolean _themeJsBarebone;
1570            private boolean _themeJsFastLoad;
1571            private String _tilesContent = StringPool.BLANK;
1572            private boolean _tilesSelectable;
1573            private String _tilesTitle = StringPool.BLANK;
1574            private TimeZone _timeZone;
1575            private List<Layout> _unfilteredLayouts;
1576            private String _urlAddContent = StringPool.BLANK;
1577            private String _urlControlPanel = StringPool.BLANK;
1578            private String _urlCurrent = StringPool.BLANK;
1579            private String _urlHome = StringPool.BLANK;
1580            private String _urlLayoutTemplates = StringPool.BLANK;
1581            private transient PortletURL _urlManageSiteMemberships = null;
1582            private transient PortletURL _urlMyAccount = null;
1583            private transient PortletURL _urlPageSettings = null;
1584            private String _urlPortal = StringPool.BLANK;
1585            private transient PortletURL _urlPublishToLive = null;
1586            private String _urlSignIn = StringPool.BLANK;
1587            private String _urlSignOut = StringPool.BLANK;
1588            private String _urlSiteAdministration = StringPool.BLANK;
1589            private transient PortletURL _urlSiteMapSettings = null;
1590            private transient PortletURL _urlSiteSettings = null;
1591            private transient PortletURL _urlUpdateManager = null;
1592            private User _user;
1593            private boolean _widget;
1594    
1595    }