001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.log.Log;
020 import com.liferay.portal.kernel.log.LogFactoryUtil;
021 import com.liferay.portal.kernel.util.PropsKeys;
022 import com.liferay.portal.kernel.util.UnicodeProperties;
023 import com.liferay.portal.kernel.util.Validator;
024 import com.liferay.portal.model.ColorScheme;
025 import com.liferay.portal.model.Group;
026 import com.liferay.portal.model.LayoutSet;
027 import com.liferay.portal.model.LayoutSetStagingHandler;
028 import com.liferay.portal.model.Theme;
029 import com.liferay.portal.service.GroupLocalServiceUtil;
030 import com.liferay.portal.service.LayoutSetLocalServiceUtil;
031 import com.liferay.portal.service.ThemeLocalServiceUtil;
032 import com.liferay.portal.util.PrefsPropsUtil;
033 import com.liferay.portlet.exportimport.staging.LayoutStagingUtil;
034
035 import java.io.IOException;
036
037
041 public class LayoutSetBranchImpl extends LayoutSetBranchBaseImpl {
042
043 @Override
044 public ColorScheme getColorScheme() {
045 return ThemeLocalServiceUtil.getColorScheme(
046 getCompanyId(), getTheme().getThemeId(), getColorSchemeId(), false);
047 }
048
049 @Override
050 public Group getGroup() throws PortalException {
051 return GroupLocalServiceUtil.getGroup(getGroupId());
052 }
053
054 @Override
055 public LayoutSet getLayoutSet() {
056 if (_layoutSet != null) {
057 return _layoutSet;
058 }
059
060 try {
061 _layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(
062 getGroupId(), getPrivateLayout());
063
064 LayoutSetStagingHandler layoutSetStagingHandler =
065 LayoutStagingUtil.getLayoutSetStagingHandler(_layoutSet);
066
067 if (layoutSetStagingHandler == null) {
068 return _layoutSet;
069 }
070
071 _layoutSet = layoutSetStagingHandler.getLayoutSet();
072
073 return _layoutSet;
074 }
075 catch (SystemException se) {
076 }
077 catch (PortalException pe) {
078 }
079
080 return _layoutSet;
081 }
082
083 @Override
084 public long getLiveLogoId() {
085 long logoId = getLayoutSet().getLogoId();
086
087 if (logoId == 0) {
088 logoId = getLayoutSet().getLiveLogoId();
089 }
090
091 return logoId;
092 }
093
094 @Override
095 public boolean getLogo() {
096 if (getLogoId() > 0) {
097 return true;
098 }
099
100 return false;
101 }
102
103 @Override
104 public String getSettings() {
105 if (_settingsProperties == null) {
106 return super.getSettings();
107 }
108 else {
109 return _settingsProperties.toString();
110 }
111 }
112
113 @Override
114 public UnicodeProperties getSettingsProperties() {
115 if (_settingsProperties == null) {
116 _settingsProperties = new UnicodeProperties(true);
117
118 try {
119 _settingsProperties.load(super.getSettings());
120 }
121 catch (IOException ioe) {
122 _log.error(ioe, ioe);
123 }
124 }
125
126 return _settingsProperties;
127 }
128
129 @Override
130 public String getSettingsProperty(String key) {
131 UnicodeProperties settingsProperties = getSettingsProperties();
132
133 return settingsProperties.getProperty(key);
134 }
135
136 @Override
137 public Theme getTheme() {
138 return ThemeLocalServiceUtil.getTheme(
139 getCompanyId(), getThemeId(), false);
140 }
141
142 @Override
143 public String getThemeSetting(String key, String device) {
144 UnicodeProperties settingsProperties = getSettingsProperties();
145
146 String value = settingsProperties.getProperty(
147 ThemeSettingImpl.namespaceProperty(device, key));
148
149 if (value != null) {
150 return value;
151 }
152
153 Theme theme = null;
154
155 boolean controlPanel = false;
156 boolean userPersonalPanel = false;
157
158 try {
159 Group group = getGroup();
160
161 controlPanel = group.isControlPanel();
162 userPersonalPanel = group.isUserPersonalPanel();
163 }
164 catch (Exception e) {
165 }
166
167 if (controlPanel || userPersonalPanel) {
168 String themeId = PrefsPropsUtil.getString(
169 getCompanyId(),
170 PropsKeys.CONTROL_PANEL_LAYOUT_REGULAR_THEME_ID);
171
172 theme = ThemeLocalServiceUtil.getTheme(
173 getCompanyId(), themeId, !device.equals("regular"));
174 }
175 else if (device.equals("regular")) {
176 theme = getTheme();
177 }
178 else {
179 theme = getWapTheme();
180 }
181
182 value = theme.getSetting(key);
183
184 return value;
185 }
186
187 @Override
188 public ColorScheme getWapColorScheme() {
189 return ThemeLocalServiceUtil.getColorScheme(
190 getCompanyId(), getWapTheme().getThemeId(), getWapColorSchemeId(),
191 true);
192 }
193
194 @Override
195 public Theme getWapTheme() {
196 return ThemeLocalServiceUtil.getTheme(
197 getCompanyId(), getWapThemeId(), true);
198 }
199
200 @Override
201 public boolean isLayoutSetPrototypeLinkActive() {
202 if (isLayoutSetPrototypeLinkEnabled() &&
203 Validator.isNotNull(getLayoutSetPrototypeUuid())) {
204
205 return true;
206 }
207
208 return false;
209 }
210
211 @Override
212 public boolean isLogo() {
213 return getLogo();
214 }
215
216 @Override
217 public void setSettings(String settings) {
218 _settingsProperties = null;
219
220 super.setSettings(settings);
221 }
222
223 @Override
224 public void setSettingsProperties(UnicodeProperties settingsProperties) {
225 _settingsProperties = settingsProperties;
226
227 super.setSettings(_settingsProperties.toString());
228 }
229
230 private static final Log _log = LogFactoryUtil.getLog(
231 LayoutSetBranchImpl.class);
232
233 private LayoutSet _layoutSet;
234 private UnicodeProperties _settingsProperties;
235
236 }