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