001    /**
002     * Copyright (c) 2000-2012 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    /**
058     * @author Brian Wing Shun Chan
059     */
060    public class ThemeDisplay
061            implements Cloneable, Mergeable<ThemeDisplay>, Serializable {
062    
063            public ThemeDisplay() {
064                    if (_log.isDebugEnabled()) {
065                            _log.debug("Creating new instance " + hashCode());
066                    }
067    
068                    _portletDisplay.setThemeDisplay(this);
069            }
070    
071            @Override
072            public Object clone() throws CloneNotSupportedException {
073                    ThemeDisplay themeDisplay = (ThemeDisplay)super.clone();
074    
075                    PortletDisplay portletDisplay = new PortletDisplay();
076    
077                    _portletDisplay.copyTo(portletDisplay);
078    
079                    themeDisplay._portletDisplay = portletDisplay;
080    
081                    portletDisplay.setThemeDisplay(themeDisplay);
082    
083                    return themeDisplay;
084            }
085    
086            public Account getAccount() {
087                    return _account;
088            }
089    
090            public String getCDNBaseURL() {
091                    if (_cdnBaseURL != null) {
092                            return _cdnBaseURL;
093                    }
094    
095                    String host = getCDNHost();
096    
097                    String portalURL = getPortalURL();
098    
099                    if (getServerName() != null) {
100                            try {
101                                    portalURL = PortalUtil.getPortalURL(getLayout(), this);
102                            }
103                            catch (Exception e) {
104                                    _log.error(e, e);
105                            }
106                    }
107    
108                    if (Validator.isNull(host)) {
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 renamed to {@link #getSiteGroup}
243             */
244            public Group getParentGroup() {
245                    return getSiteGroup();
246            }
247    
248            /**
249             * @deprecated As of 6.2 renamed to {@link #getSiteGroupId}
250             */
251            public long getParentGroupId() {
252                    return getSiteGroupId();
253            }
254    
255            /**
256             * @deprecated As of 6.2 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 Use <code>getPathThemeImages</code>.
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 Use <code>getScopeGroupId</code>.
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 getRefererPlid() {
385                    return _refererPlid;
386            }
387    
388            public Group getScopeGroup() {
389                    return _scopeGroup;
390            }
391    
392            public long getScopeGroupId() {
393                    return _scopeGroupId;
394            }
395    
396            /**
397             * @deprecated As of 6.2 renamed to {@link #getSiteGroupIdOrLiveGroupId}
398             */
399            public long getScopeGroupIdOrLiveGroupId()
400                    throws PortalException, SystemException {
401    
402                    return getSiteGroupIdOrLiveGroupId();
403            }
404    
405            public String getScopeGroupName() throws PortalException, SystemException {
406                    if (_scopeGroup == null) {
407                            return StringPool.BLANK;
408                    }
409                    else {
410                            return _scopeGroup.getDescriptiveName();
411                    }
412            }
413    
414            public Layout getScopeLayout() throws PortalException, SystemException {
415                    if (_layout.hasScopeGroup()) {
416                            return _layout;
417                    }
418                    else if (_scopeGroup.isLayout()) {
419                            return LayoutLocalServiceUtil.getLayout(_scopeGroup.getClassPK());
420                    }
421                    else {
422                            return null;
423                    }
424            }
425    
426            public String getServerName() {
427                    return _serverName;
428            }
429    
430            public int getServerPort() {
431                    return _serverPort;
432            }
433    
434            public String getSessionId() {
435                    return _sessionId;
436            }
437    
438            public Group getSiteGroup() {
439                    return _siteGroup;
440            }
441    
442            public long getSiteGroupId() {
443                    return _siteGroupId;
444            }
445    
446            public long getSiteGroupIdOrLiveGroupId()
447                    throws PortalException, SystemException {
448    
449                    return StagingUtil.getLiveGroupId(_siteGroupId);
450            }
451    
452            public String getSiteGroupName() throws PortalException, SystemException {
453                    if (_siteGroup == null) {
454                            return StringPool.BLANK;
455                    }
456                    else {
457                            return _siteGroup.getDescriptiveName();
458                    }
459            }
460    
461            public Theme getTheme() {
462                    return _theme;
463            }
464    
465            public String getThemeId() {
466                    return _theme.getThemeId();
467            }
468    
469            public String getThemeSetting(String key) {
470                    Theme theme = getTheme();
471    
472                    String device = theme.getDevice();
473    
474                    Layout layout = getLayout();
475    
476                    return layout.getThemeSetting(key, device);
477            }
478    
479            public Properties getThemeSettings() {
480                    Theme theme = getTheme();
481    
482                    Properties properties = new Properties();
483    
484                    Map<String, ThemeSetting> themeSettings = theme.getSettings();
485    
486                    for (String key : themeSettings.keySet()) {
487                            ThemeSetting themeSetting = themeSettings.get(key);
488    
489                            String value = null;
490    
491                            if (themeSetting.isConfigurable()) {
492                                    value = getThemeSetting(key);
493                            }
494                            else {
495                                    value = themeSetting.getValue();
496                            }
497    
498                            if (value != null) {
499                                    properties.put(key, value);
500                            }
501                    }
502    
503                    return properties;
504            }
505    
506            public String getTilesContent() {
507                    return _tilesContent;
508            }
509    
510            public String getTilesTitle() {
511                    return _tilesTitle;
512            }
513    
514            public TimeZone getTimeZone() {
515                    return _timeZone;
516            }
517    
518            public List<Layout> getUnfilteredLayouts() {
519                    return _unfilteredLayouts;
520            }
521    
522            public String getURLAddContent() {
523                    return _urlAddContent;
524            }
525    
526            public String getURLControlPanel() {
527                    return _urlControlPanel;
528            }
529    
530            public String getURLCurrent() {
531                    return _urlCurrent;
532            }
533    
534            public String getURLHome() {
535                    return _urlHome;
536            }
537    
538            public String getURLLayoutTemplates() {
539                    if (Validator.isNull(_urlLayoutTemplates)) {
540                            return _urlPageSettings + "#layout";
541                    }
542    
543                    return _urlLayoutTemplates;
544            }
545    
546            public PortletURL getURLManageSiteMemberships() {
547                    return _urlManageSiteMemberships;
548            }
549    
550            public PortletURL getURLMyAccount() {
551                    return _urlMyAccount;
552            }
553    
554            public PortletURL getURLPageSettings() {
555                    return _urlPageSettings;
556            }
557    
558            public String getURLPortal() {
559                    return _urlPortal;
560            }
561    
562            public PortletURL getURLPublishToLive() {
563                    return _urlPublishToLive;
564            }
565    
566            public String getURLSignIn() {
567                    return _urlSignIn;
568            }
569    
570            public String getURLSignOut() {
571                    return _urlSignOut;
572            }
573    
574            public String getURLSiteContent() {
575                    return _urlSiteContent;
576            }
577    
578            public PortletURL getURLSiteMapSettings() {
579                    return _urlSiteMapSettings;
580            }
581    
582            public PortletURL getURLSiteSettings() {
583                    return _urlSiteSettings;
584            }
585    
586            public PortletURL getURLUpdateManager() {
587                    return _urlUpdateManager;
588            }
589    
590            public User getUser() {
591                    return _user;
592            }
593    
594            public long getUserId() {
595                    return _user.getUserId();
596            }
597    
598            public boolean isAddSessionIdToURL() {
599                    return _addSessionIdToURL;
600            }
601    
602            public boolean isAjax() {
603                    return _ajax;
604            }
605    
606            public boolean isFacebook() {
607                    return _facebook;
608            }
609    
610            public boolean isFreeformLayout() {
611                    return _freeformLayout;
612            }
613    
614            public boolean isI18n() {
615                    return _i18n;
616            }
617    
618            public boolean isImpersonated() {
619                    if (getUserId() == getRealUserId()) {
620                            return false;
621                    }
622                    else {
623                            return true;
624                    }
625            }
626    
627            public boolean isIncludedJs(String js) {
628                    String path = getPathJavaScript();
629    
630                    if (isIncludePortletCssJs() &&
631                            js.startsWith(path + "/liferay/portlet_css.js")) {
632    
633                            return true;
634                    }
635                    else {
636                            return false;
637                    }
638            }
639    
640            public boolean isIncludePortletCssJs() {
641                    return _includePortletCssJs;
642            }
643    
644            public boolean isIsolated() {
645                    return _isolated;
646            }
647    
648            public boolean isLifecycleAction() {
649                    return _lifecycleAction;
650            }
651    
652            public boolean isLifecycleEvent() {
653                    return _lifecycleEvent;
654            }
655    
656            public boolean isLifecycleRender() {
657                    return _lifecycleRender;
658            }
659    
660            public boolean isLifecycleResource() {
661                    return _lifecycleResource;
662            }
663    
664            public boolean isSecure() {
665                    return _secure;
666            }
667    
668            public boolean isShowAddContentIcon() {
669                    return _showAddContentIcon;
670            }
671    
672            public boolean isShowAddContentIconPermission() {
673                    return _showAddContentIconPermission;
674            }
675    
676            public boolean isShowControlPanelIcon() {
677                    return _showControlPanelIcon;
678            }
679    
680            public boolean isShowHomeIcon() {
681                    return _showHomeIcon;
682            }
683    
684            public boolean isShowLayoutTemplatesIcon() {
685                    return _showLayoutTemplatesIcon;
686            }
687    
688            public boolean isShowManageSiteMembershipsIcon() {
689                    return _showManageSiteMembershipsIcon;
690            }
691    
692            public boolean isShowMyAccountIcon() {
693                    return _showMyAccountIcon;
694            }
695    
696            public boolean isShowPageCustomizationIcon() {
697                    return _showPageCustomizationIcon;
698            }
699    
700            public boolean isShowPageSettingsIcon() {
701                    return _showPageSettingsIcon;
702            }
703    
704            public boolean isShowPortalIcon() {
705                    return _showPortalIcon;
706            }
707    
708            public boolean isShowSignInIcon() {
709                    return _showSignInIcon;
710            }
711    
712            public boolean isShowSignOutIcon() {
713                    return _showSignOutIcon;
714            }
715    
716            public boolean isShowSiteContentIcon() {
717                    return _showSiteContentIcon;
718            }
719    
720            public boolean isShowSiteMapSettingsIcon() {
721                    return _showSiteMapSettingsIcon;
722            }
723    
724            public boolean isShowSiteSettingsIcon() {
725                    return _showSiteSettingsIcon;
726            }
727    
728            public boolean isShowStagingIcon() {
729                    return _showStagingIcon;
730            }
731    
732            public boolean isSignedIn() {
733                    return _signedIn;
734            }
735    
736            public boolean isStateExclusive() {
737                    return _stateExclusive;
738            }
739    
740            public boolean isStateMaximized() {
741                    return _stateMaximized;
742            }
743    
744            public boolean isStatePopUp() {
745                    return _statePopUp;
746            }
747    
748            public boolean isThemeCssFastLoad() {
749                    return _themeCssFastLoad;
750            }
751    
752            public boolean isThemeImagesFastLoad() {
753                    return _themeImagesFastLoad;
754            }
755    
756            public boolean isThemeJsBarebone() {
757                    return _themeJsBarebone;
758            }
759    
760            public boolean isThemeJsFastLoad() {
761                    return _themeJsFastLoad;
762            }
763    
764            public boolean isTilesSelectable() {
765                    return _tilesSelectable;
766            }
767    
768            public boolean isWapTheme() {
769                    return _theme.isWapTheme();
770            }
771    
772            public boolean isWidget() {
773                    return _widget;
774            }
775    
776            public ThemeDisplay merge(ThemeDisplay themeDisplay) {
777                    if ((themeDisplay == null) || (themeDisplay == this)) {
778                            return this;
779                    }
780    
781                    _includePortletCssJs = themeDisplay._includePortletCssJs;
782    
783                    return this;
784            }
785    
786            public void setAccount(Account account) {
787                    _account = account;
788            }
789    
790            public void setAddSessionIdToURL(boolean addSessionIdToURL) {
791                    _addSessionIdToURL = addSessionIdToURL;
792            }
793    
794            public void setAjax(boolean ajax) {
795                    _ajax = ajax;
796            }
797    
798            public void setCDNBaseURL(String cdnBase) {
799                    _cdnBaseURL = cdnBase;
800            }
801    
802            public void setCDNDynamicResourcesHost(String cdnDynamicResourcesHost) {
803                    _cdnDynamicResourcesHost = cdnDynamicResourcesHost;
804            }
805    
806            public void setCDNHost(String cdnHost) {
807                    _cdnHost = cdnHost;
808            }
809    
810            public void setCompany(Company company)
811                    throws PortalException, SystemException {
812    
813                    _company = company;
814                    _companyGroupId = company.getGroup().getGroupId();
815    
816                    setAccount(company.getAccount());
817            }
818    
819            public void setCompanyLogo(String companyLogo) {
820                    _companyLogo = companyLogo;
821            }
822    
823            public void setCompanyLogoHeight(int companyLogoHeight) {
824                    _companyLogoHeight = companyLogoHeight;
825            }
826    
827            public void setCompanyLogoWidth(int companyLogoWidth) {
828                    _companyLogoWidth = companyLogoWidth;
829            }
830    
831            public void setContact(Contact contact) {
832                    _contact = contact;
833            }
834    
835            public void setControlPanelCategory(String controlPanelCategory) {
836                    _controlPanelCategory = controlPanelCategory;
837            }
838    
839            public void setDevice(Device device) {
840                    _device = device;
841            }
842    
843            public void setDoAsGroupId(long doAsGroupId) {
844                    _doAsGroupId = doAsGroupId;
845            }
846    
847            public void setDoAsUserId(String doAsUserId) {
848                    _doAsUserId = doAsUserId;
849            }
850    
851            public void setDoAsUserLanguageId(String doAsUserLanguageId) {
852                    _doAsUserLanguageId = doAsUserLanguageId;
853            }
854    
855            public void setFacebookCanvasPageURL(String facebookCanvasPageURL) {
856                    _facebookCanvasPageURL = facebookCanvasPageURL;
857    
858                    if (Validator.isNotNull(facebookCanvasPageURL)) {
859                            _facebook = true;
860                    }
861            }
862    
863            public void setFreeformLayout(boolean freeformLayout) {
864                    _freeformLayout = freeformLayout;
865            }
866    
867            public void setI18nLanguageId(String i18nLanguageId) {
868                    _i18nLanguageId = i18nLanguageId;
869    
870                    if (Validator.isNotNull(i18nLanguageId)) {
871                            _i18n = true;
872                    }
873                    else {
874                            _i18n = false;
875                    }
876            }
877    
878            public void setI18nPath(String i18nPath) {
879                    _i18nPath = i18nPath;
880    
881                    if (Validator.isNotNull(i18nPath)) {
882                            _i18n = true;
883                    }
884                    else {
885                            _i18n = false;
886                    }
887            }
888    
889            public void setIncludePortletCssJs(boolean includePortletCssJs) {
890                    _includePortletCssJs = includePortletCssJs;
891            }
892    
893            public void setIsolated(boolean isolated) {
894                    _isolated = isolated;
895            }
896    
897            public void setLanguageId(String languageId) {
898                    _languageId = languageId;
899            }
900    
901            public void setLayout(Layout layout) {
902                    _layout = layout;
903            }
904    
905            public void setLayouts(List<Layout> layouts) {
906                    _layouts = layouts;
907            }
908    
909            public void setLayoutSet(LayoutSet layoutSet) {
910                    _layoutSet = layoutSet;
911            }
912    
913            public void setLayoutSetLogo(String layoutSetLogo) {
914                    _layoutSetLogo = layoutSetLogo;
915            }
916    
917            public void setLayoutTypePortlet(LayoutTypePortlet layoutTypePortlet) {
918                    _layoutTypePortlet = layoutTypePortlet;
919            }
920    
921            public void setLifecycle(String lifecycle) {
922                    _lifecycle = lifecycle;
923            }
924    
925            public void setLifecycleAction(boolean lifecycleAction) {
926                    _lifecycleAction = lifecycleAction;
927            }
928    
929            public void setLifecycleEvent(boolean lifecycleEvent) {
930                    _lifecycleEvent = lifecycleEvent;
931            }
932    
933            public void setLifecycleRender(boolean lifecycleRender) {
934                    _lifecycleRender = lifecycleRender;
935            }
936    
937            public void setLifecycleResource(boolean lifecycleResource) {
938                    _lifecycleResource = lifecycleResource;
939            }
940    
941            public void setLocale(Locale locale) {
942                    _locale = locale;
943    
944                    LocaleThreadLocal.setThemeDisplayLocale(locale);
945            }
946    
947            public void setLookAndFeel(Theme theme, ColorScheme colorScheme) {
948                    _theme = theme;
949                    _colorScheme = colorScheme;
950    
951                    if ((theme != null) && (colorScheme != null)) {
952                            String themeStaticResourcePath = theme.getStaticResourcePath();
953    
954                            String cdnBaseURL = getCDNBaseURL();
955    
956                            setPathColorSchemeImages(
957                                    cdnBaseURL + themeStaticResourcePath +
958                                            colorScheme.getColorSchemeImagesPath());
959    
960                            String dynamicResourcesHost = getCDNDynamicResourcesHost();
961    
962                            if (Validator.isNull(dynamicResourcesHost)) {
963                                    String portalURL = getPortalURL();
964    
965                                    if (getServerName() != null) {
966                                            try {
967                                                    portalURL = PortalUtil.getPortalURL(getLayout(), this);
968                                            }
969                                            catch (Exception e) {
970                                                    _log.error(e, e);
971                                            }
972                                    }
973    
974                                    dynamicResourcesHost = portalURL;
975                            }
976    
977                            setPathThemeCss(
978                                    dynamicResourcesHost + themeStaticResourcePath +
979                                            theme.getCssPath());
980    
981                            setPathThemeImages(
982                                    cdnBaseURL + themeStaticResourcePath + theme.getImagesPath());
983                            setPathThemeJavaScript(
984                                    cdnBaseURL + themeStaticResourcePath +
985                                            theme.getJavaScriptPath());
986                            setPathThemeRoot(themeStaticResourcePath + theme.getRootPath());
987                            setPathThemeTemplates(
988                                    cdnBaseURL + themeStaticResourcePath +
989                                            theme.getTemplatesPath());
990                    }
991            }
992    
993            public void setMDRRuleGroupInstance(
994                    MDRRuleGroupInstance mdrRuleGroupInstance) {
995    
996                    _mdrRuleGroupInstance = mdrRuleGroupInstance;
997            }
998    
999            /**
1000             * @deprecated As of 6.2 renamed to {@link #setSiteGroupId(long)}
1001             */
1002            public void setParentGroupId(long parentGroupId) {
1003                    setSiteGroupId(parentGroupId);
1004            }
1005    
1006            public void setPathApplet(String pathApplet) {
1007                    _pathApplet = pathApplet;
1008            }
1009    
1010            public void setPathCms(String pathCms) {
1011                    _pathCms = pathCms;
1012            }
1013    
1014            public void setPathColorSchemeImages(String pathColorSchemeImages) {
1015                    _pathColorSchemeImages = pathColorSchemeImages;
1016            }
1017    
1018            public void setPathContext(String pathContext) {
1019                    _pathContext = pathContext;
1020            }
1021    
1022            public void setPathFlash(String pathFlash) {
1023                    _pathFlash = pathFlash;
1024            }
1025    
1026            public void setPathFriendlyURLPrivateGroup(
1027                    String pathFriendlyURLPrivateGroup) {
1028    
1029                    _pathFriendlyURLPrivateGroup = pathFriendlyURLPrivateGroup;
1030            }
1031    
1032            public void setPathFriendlyURLPrivateUser(
1033                    String pathFriendlyURLPrivateUser) {
1034    
1035                    _pathFriendlyURLPrivateUser = pathFriendlyURLPrivateUser;
1036            }
1037    
1038            public void setPathFriendlyURLPublic(String pathFriendlyURLPublic) {
1039                    _pathFriendlyURLPublic = pathFriendlyURLPublic;
1040            }
1041    
1042            public void setPathImage(String pathImage) {
1043                    if (isFacebook() &&
1044                            !pathImage.startsWith(Http.HTTP_WITH_SLASH) &&
1045                            !pathImage.startsWith(Http.HTTPS_WITH_SLASH)) {
1046    
1047                            pathImage = getPortalURL() + pathImage;
1048                    }
1049    
1050                    _pathImage = pathImage;
1051            }
1052    
1053            public void setPathJavaScript(String pathJavaScript) {
1054                    _pathJavaScript = pathJavaScript;
1055            }
1056    
1057            public void setPathMain(String pathMain) {
1058                    _pathMain = pathMain;
1059            }
1060    
1061            public void setPathSound(String pathSound) {
1062                    _pathSound = pathSound;
1063            }
1064    
1065            public void setPathThemeCss(String pathThemeCss) {
1066                    _pathThemeCss = pathThemeCss;
1067            }
1068    
1069            public void setPathThemeImages(String pathThemeImages) {
1070                    _pathThemeImages = pathThemeImages;
1071            }
1072    
1073            public void setPathThemeJavaScript(String pathThemeJavaScript) {
1074                    _pathThemeJavaScript = pathThemeJavaScript;
1075            }
1076    
1077            public void setPathThemeRoot(String pathThemeRoot) {
1078                    _pathThemeRoot = pathThemeRoot;
1079            }
1080    
1081            public void setPathThemeTemplates(String pathThemeTemplates) {
1082                    _pathThemeTemplates = pathThemeTemplates;
1083            }
1084    
1085            public void setPermissionChecker(PermissionChecker permissionChecker) {
1086                    _permissionChecker = permissionChecker;
1087            }
1088    
1089            public void setPlid(long plid) {
1090                    _plid = plid;
1091            }
1092    
1093            public void setPortalURL(String portalURL) {
1094                    _portalURL = portalURL;
1095            }
1096    
1097            public void setPpid(String ppid) {
1098                    _ppid = ppid;
1099            }
1100    
1101            public void setRealCompanyLogo(String realCompanyLogo) {
1102                    _realCompanyLogo = realCompanyLogo;
1103            }
1104    
1105            public void setRealCompanyLogoHeight(int realCompanyLogoHeight) {
1106                    _realCompanyLogoHeight = realCompanyLogoHeight;
1107            }
1108    
1109            public void setRealCompanyLogoWidth(int realCompanyLogoWidth) {
1110                    _realCompanyLogoWidth = realCompanyLogoWidth;
1111            }
1112    
1113            public void setRealUser(User realUser) {
1114                    _realUser = realUser;
1115            }
1116    
1117            public void setRefererPlid(long refererPlid) {
1118                    _refererPlid = refererPlid;
1119            }
1120    
1121            public void setScopeGroupId(long scopeGroupId) {
1122                    _scopeGroupId = scopeGroupId;
1123    
1124                    if (_scopeGroupId > 0) {
1125                            try {
1126                                    _scopeGroup = GroupLocalServiceUtil.getGroup(_scopeGroupId);
1127                            }
1128                            catch (Exception e) {
1129                                    _log.error(e, e);
1130                            }
1131                    }
1132            }
1133    
1134            public void setSecure(boolean secure) {
1135                    _secure = secure;
1136            }
1137    
1138            public void setServerName(String serverName) {
1139                    _serverName = serverName;
1140            }
1141    
1142            public void setServerPort(int serverPort) {
1143                    _serverPort = serverPort;
1144            }
1145    
1146            public void setSessionId(String sessionId) {
1147                    _sessionId = sessionId;
1148            }
1149    
1150            public void setShowAddContentIcon(boolean showAddContentIcon) {
1151                    _showAddContentIcon = showAddContentIcon;
1152            }
1153    
1154            public void setShowAddContentIconPermission(
1155                    boolean showAddContentIconPermission) {
1156    
1157                    _showAddContentIconPermission = showAddContentIconPermission;
1158            }
1159    
1160            public void setShowControlPanelIcon(boolean showControlPanelIcon) {
1161                    _showControlPanelIcon = showControlPanelIcon;
1162            }
1163    
1164            public void setShowHomeIcon(boolean showHomeIcon) {
1165                    _showHomeIcon = showHomeIcon;
1166            }
1167    
1168            public void setShowLayoutTemplatesIcon(boolean showLayoutTemplatesIcon) {
1169                    _showLayoutTemplatesIcon = showLayoutTemplatesIcon;
1170            }
1171    
1172            public void setShowManageSiteMembershipsIcon(
1173                    boolean showManageSiteMembershipsIcon) {
1174    
1175                    _showManageSiteMembershipsIcon = showManageSiteMembershipsIcon;
1176            }
1177    
1178            public void setShowMyAccountIcon(boolean showMyAccountIcon) {
1179                    _showMyAccountIcon = showMyAccountIcon;
1180            }
1181    
1182            public void setShowPageCustomizationIcon(
1183                    boolean showPageCustomizationIcon) {
1184    
1185                    _showPageCustomizationIcon = showPageCustomizationIcon;
1186            }
1187    
1188            public void setShowPageSettingsIcon(boolean showPageSettingsIcon) {
1189                    _showPageSettingsIcon = showPageSettingsIcon;
1190            }
1191    
1192            public void setShowPortalIcon(boolean showPortalIcon) {
1193                    _showPortalIcon = showPortalIcon;
1194            }
1195    
1196            public void setShowSignInIcon(boolean showSignInIcon) {
1197                    _showSignInIcon = showSignInIcon;
1198            }
1199    
1200            public void setShowSignOutIcon(boolean showSignOutIcon) {
1201                    _showSignOutIcon = showSignOutIcon;
1202            }
1203    
1204            public void setShowSiteContentIcon(boolean showSiteContentIcon) {
1205                    _showSiteContentIcon = showSiteContentIcon;
1206            }
1207    
1208            public void setShowSiteMapSettingsIcon(boolean showSiteMapSettingsIcon) {
1209                    _showSiteMapSettingsIcon = showSiteMapSettingsIcon;
1210            }
1211    
1212            public void setShowSiteSettingsIcon(boolean showSiteSettingsIcon) {
1213                    _showSiteSettingsIcon = showSiteSettingsIcon;
1214            }
1215    
1216            public void setShowStagingIcon(boolean showStagingIcon) {
1217                    _showStagingIcon = showStagingIcon;
1218            }
1219    
1220            public void setSignedIn(boolean signedIn) {
1221                    _signedIn = signedIn;
1222            }
1223    
1224            public void setSiteGroupId(long siteGroupId) {
1225                    _siteGroupId = siteGroupId;
1226    
1227                    if (_siteGroupId > 0) {
1228                            try {
1229                                    _siteGroup = GroupLocalServiceUtil.getGroup(_siteGroupId);
1230                            }
1231                            catch (Exception e) {
1232                                    _log.error(e, e);
1233                            }
1234                    }
1235            }
1236    
1237            public void setStateExclusive(boolean stateExclusive) {
1238                    _stateExclusive = stateExclusive;
1239            }
1240    
1241            public void setStateMaximized(boolean stateMaximized) {
1242                    _stateMaximized = stateMaximized;
1243            }
1244    
1245            public void setStatePopUp(boolean statePopUp) {
1246                    _statePopUp = statePopUp;
1247            }
1248    
1249            public void setThemeCssFastLoad(boolean themeCssFastLoad) {
1250                    _themeCssFastLoad = themeCssFastLoad;
1251            }
1252    
1253            public void setThemeImagesFastLoad(boolean themeImagesFastLoad) {
1254                    _themeImagesFastLoad = themeImagesFastLoad;
1255            }
1256    
1257            public void setThemeJsBarebone(boolean themeJsBarebone) {
1258                    _themeJsBarebone = themeJsBarebone;
1259            }
1260    
1261            public void setThemeJsFastLoad(boolean themeJsFastLoad) {
1262                    _themeJsFastLoad = themeJsFastLoad;
1263            }
1264    
1265            public void setTilesContent(String tilesContent) {
1266                    _tilesContent = tilesContent;
1267            }
1268    
1269            public void setTilesSelectable(boolean tilesSelectable) {
1270                    _tilesSelectable = tilesSelectable;
1271            }
1272    
1273            public void setTilesTitle(String tilesTitle) {
1274                    _tilesTitle = tilesTitle;
1275            }
1276    
1277            public void setTimeZone(TimeZone timeZone) {
1278                    _timeZone = timeZone;
1279    
1280                    TimeZoneThreadLocal.setThemeDisplayTimeZone(timeZone);
1281            }
1282    
1283            public void setUnfilteredLayouts(List<Layout> unfilteredLayouts) {
1284                    _unfilteredLayouts = unfilteredLayouts;
1285            }
1286    
1287            public void setURLAddContent(String urlAddContent) {
1288                    _urlAddContent = urlAddContent;
1289            }
1290    
1291            public void setURLControlPanel(String urlControlPanel) {
1292                    _urlControlPanel = urlControlPanel;
1293            }
1294    
1295            public void setURLCurrent(String urlCurrent) {
1296                    _urlCurrent = urlCurrent;
1297            }
1298    
1299            public void setURLHome(String urlHome) {
1300                    _urlHome = urlHome;
1301            }
1302    
1303            public void setURLLayoutTemplates(String urlLayoutTemplates) {
1304                    _urlLayoutTemplates = urlLayoutTemplates;
1305            }
1306    
1307            public void setURLManageSiteMemberships(
1308                    PortletURL urlManageSiteMemberships) {
1309    
1310                    _urlManageSiteMemberships = urlManageSiteMemberships;
1311            }
1312    
1313            public void setURLMyAccount(PortletURL urlMyAccount) {
1314                    _urlMyAccount = urlMyAccount;
1315            }
1316    
1317            public void setURLPageSettings(PortletURL urlPageSettings) {
1318                    _urlPageSettings = urlPageSettings;
1319            }
1320    
1321            public void setURLPortal(String urlPortal) {
1322                    _urlPortal = urlPortal;
1323            }
1324    
1325            public void setURLPublishToLive(PortletURL urlPublishToLive) {
1326                    _urlPublishToLive = urlPublishToLive;
1327            }
1328    
1329            public void setURLSignIn(String urlSignIn) {
1330                    _urlSignIn = urlSignIn;
1331            }
1332    
1333            public void setURLSignOut(String urlSignOut) {
1334                    _urlSignOut = urlSignOut;
1335            }
1336    
1337            public void setURLSiteContent(String urlSiteContent) {
1338                    _urlSiteContent = urlSiteContent;
1339            }
1340    
1341            public void setURLSiteMapSettings(PortletURL urlSiteMapSettings) {
1342                    _urlSiteMapSettings = urlSiteMapSettings;
1343            }
1344    
1345            public void setURLSiteSettings(PortletURL urlSiteSettings) {
1346                    _urlSiteSettings = urlSiteSettings;
1347            }
1348    
1349            public void setURLUpdateManager(PortletURL urlUpdateManager) {
1350                    _urlUpdateManager = urlUpdateManager;
1351            }
1352    
1353            public void setUser(User user) throws PortalException, SystemException {
1354                    _user = user;
1355    
1356                    setContact(user.getContact());
1357            }
1358    
1359            public void setWidget(boolean widget) {
1360                    _widget = widget;
1361            }
1362    
1363            public String translate(String key) {
1364                    return LanguageUtil.get(getLocale(), key);
1365            }
1366    
1367            public String translate(String pattern, Object argument) {
1368                    return LanguageUtil.format(getLocale(), pattern, argument);
1369            }
1370    
1371            public String translate(String pattern, Object[] arguments) {
1372                    return LanguageUtil.format(getLocale(), pattern, arguments);
1373            }
1374    
1375            private static Log _log = LogFactoryUtil.getLog(ThemeDisplay.class);
1376    
1377            private Account _account;
1378            private boolean _addSessionIdToURL;
1379            private boolean _ajax;
1380            private String _cdnBaseURL;
1381            private String _cdnDynamicResourcesHost = StringPool.BLANK;
1382            private String _cdnHost = StringPool.BLANK;
1383            private ColorScheme _colorScheme;
1384            private Company _company;
1385            private long _companyGroupId;
1386            private String _companyLogo = StringPool.BLANK;
1387            private int _companyLogoHeight;
1388            private int _companyLogoWidth;
1389            private Contact _contact;
1390            private String _controlPanelCategory = StringPool.BLANK;
1391            private User _defaultUser;
1392            private Device _device;
1393            private long _doAsGroupId = 0;
1394            private String _doAsUserId = StringPool.BLANK;
1395            private String _doAsUserLanguageId = StringPool.BLANK;
1396            private boolean _facebook;
1397            private String _facebookCanvasPageURL;
1398            private boolean _freeformLayout;
1399            private boolean _i18n;
1400            private String _i18nLanguageId;
1401            private String _i18nPath;
1402            private boolean _includePortletCssJs;
1403            private boolean _isolated;
1404            private String _languageId;
1405            private Layout _layout;
1406            private List<Layout> _layouts;
1407            private LayoutSet _layoutSet;
1408            private String _layoutSetLogo = StringPool.BLANK;
1409            private LayoutTypePortlet _layoutTypePortlet;
1410            private String _lifecycle;
1411            private boolean _lifecycleAction;
1412            private boolean _lifecycleEvent;
1413            private boolean _lifecycleRender;
1414            private boolean _lifecycleResource;
1415            private Locale _locale;
1416            private MDRRuleGroupInstance _mdrRuleGroupInstance;
1417            private String _pathApplet = StringPool.BLANK;
1418            private String _pathCms = StringPool.BLANK;
1419            private String _pathColorSchemeImages = StringPool.BLANK;
1420            private String _pathContext = StringPool.BLANK;
1421            private String _pathFlash = StringPool.BLANK;
1422            private String _pathFriendlyURLPrivateGroup = StringPool.BLANK;
1423            private String _pathFriendlyURLPrivateUser = StringPool.BLANK;
1424            private String _pathFriendlyURLPublic = StringPool.BLANK;
1425            private String _pathImage = StringPool.BLANK;
1426            private String _pathJavaScript = StringPool.BLANK;
1427            private String _pathMain = StringPool.BLANK;
1428            private String _pathSound = StringPool.BLANK;
1429            private String _pathThemeCss = StringPool.BLANK;
1430            private String _pathThemeImages = StringPool.BLANK;
1431            private String _pathThemeJavaScript = StringPool.BLANK;
1432            private String _pathThemeRoot = StringPool.BLANK;
1433            private String _pathThemeTemplates = StringPool.BLANK;
1434            private transient PermissionChecker _permissionChecker;
1435            private long _plid;
1436            private String _portalURL = StringPool.BLANK;
1437            private PortletDisplay _portletDisplay = new PortletDisplay();
1438            private String _ppid = StringPool.BLANK;
1439            private String _realCompanyLogo = StringPool.BLANK;
1440            private int _realCompanyLogoHeight;
1441            private int _realCompanyLogoWidth;
1442            private User _realUser;
1443            private long _refererPlid;
1444            private Group _scopeGroup;
1445            private long _scopeGroupId;
1446            private boolean _secure;
1447            private String _serverName;
1448            private int _serverPort;
1449            private String _sessionId = StringPool.BLANK;
1450            private boolean _showAddContentIcon;
1451            private boolean _showAddContentIconPermission;
1452            private boolean _showControlPanelIcon;
1453            private boolean _showHomeIcon;
1454            private boolean _showLayoutTemplatesIcon;
1455            private boolean _showManageSiteMembershipsIcon;
1456            private boolean _showMyAccountIcon;
1457            private boolean _showPageCustomizationIcon;
1458            private boolean _showPageSettingsIcon;
1459            private boolean _showPortalIcon;
1460            private boolean _showSignInIcon;
1461            private boolean _showSignOutIcon;
1462            private boolean _showSiteContentIcon;
1463            private boolean _showSiteMapSettingsIcon;
1464            private boolean _showSiteSettingsIcon;
1465            private boolean _showStagingIcon;
1466            private boolean _signedIn;
1467            private Group _siteGroup;
1468            private long _siteGroupId;
1469            private boolean _stateExclusive;
1470            private boolean _stateMaximized;
1471            private boolean _statePopUp;
1472            private Theme _theme;
1473            private boolean _themeCssFastLoad;
1474            private boolean _themeImagesFastLoad;
1475            private boolean _themeJsBarebone;
1476            private boolean _themeJsFastLoad;
1477            private String _tilesContent = StringPool.BLANK;
1478            private boolean _tilesSelectable;
1479            private String _tilesTitle = StringPool.BLANK;
1480            private TimeZone _timeZone;
1481            private List<Layout> _unfilteredLayouts;
1482            private String _urlAddContent = StringPool.BLANK;
1483            private String _urlControlPanel = StringPool.BLANK;
1484            private String _urlCurrent = StringPool.BLANK;
1485            private String _urlHome = StringPool.BLANK;
1486            private String _urlLayoutTemplates = StringPool.BLANK;
1487            private transient PortletURL _urlManageSiteMemberships = null;
1488            private transient PortletURL _urlMyAccount = null;
1489            private transient PortletURL _urlPageSettings = null;
1490            private String _urlPortal = StringPool.BLANK;
1491            private transient PortletURL _urlPublishToLive = null;
1492            private String _urlSignIn = StringPool.BLANK;
1493            private String _urlSignOut = StringPool.BLANK;
1494            private String _urlSiteContent = StringPool.BLANK;
1495            private transient PortletURL _urlSiteMapSettings = null;
1496            private transient PortletURL _urlSiteSettings = null;
1497            private transient PortletURL _urlUpdateManager = null;
1498            private User _user;
1499            private boolean _widget;
1500    
1501    }