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.util.LocaleUtil;
020 import com.liferay.portal.kernel.util.UnicodeProperties;
021 import com.liferay.portal.kernel.util.Validator;
022 import com.liferay.portal.model.ColorScheme;
023 import com.liferay.portal.model.LayoutBranch;
024 import com.liferay.portal.model.LayoutRevision;
025 import com.liferay.portal.model.LayoutSet;
026 import com.liferay.portal.model.LayoutTypePortletConstants;
027 import com.liferay.portal.model.Theme;
028 import com.liferay.portal.service.LayoutBranchLocalServiceUtil;
029 import com.liferay.portal.service.LayoutRevisionLocalServiceUtil;
030 import com.liferay.portal.service.LayoutSetLocalServiceUtil;
031 import com.liferay.portal.service.ThemeLocalServiceUtil;
032
033 import java.util.List;
034 import java.util.Locale;
035
036
039 public class LayoutRevisionImpl extends LayoutRevisionBaseImpl {
040
041 public LayoutRevisionImpl() {
042 }
043
044 @Override
045 public List<LayoutRevision> getChildren() throws SystemException {
046 return LayoutRevisionLocalServiceUtil.getChildLayoutRevisions(
047 getLayoutSetBranchId(), getLayoutRevisionId(), getPlid());
048 }
049
050 @Override
051 public ColorScheme getColorScheme()
052 throws PortalException, SystemException {
053
054 if (isInheritLookAndFeel()) {
055 return getLayoutSet().getColorScheme();
056 }
057 else {
058 return ThemeLocalServiceUtil.getColorScheme(
059 getCompanyId(), getTheme().getThemeId(), getColorSchemeId(),
060 false);
061 }
062 }
063
064 @Override
065 public String getCssText() throws PortalException, SystemException {
066 if (isInheritLookAndFeel()) {
067 return getLayoutSet().getCss();
068 }
069 else {
070 return getCss();
071 }
072 }
073
074 @Override
075 public String getHTMLTitle(Locale locale) {
076 String localeLanguageId = LocaleUtil.toLanguageId(locale);
077
078 return getHTMLTitle(localeLanguageId);
079 }
080
081 @Override
082 public String getHTMLTitle(String localeLanguageId) {
083 String htmlTitle = getTitle(localeLanguageId);
084
085 if (Validator.isNull(htmlTitle)) {
086 htmlTitle = getName(localeLanguageId);
087 }
088
089 return htmlTitle;
090 }
091
092 @Override
093 public LayoutBranch getLayoutBranch()
094 throws PortalException, SystemException {
095
096 return LayoutBranchLocalServiceUtil.getLayoutBranch(
097 getLayoutBranchId());
098 }
099
100 @Override
101 public LayoutSet getLayoutSet() throws PortalException, SystemException {
102 return LayoutSetLocalServiceUtil.getLayoutSet(
103 getGroupId(), isPrivateLayout());
104 }
105
106 @Override
107 public Theme getTheme() throws PortalException, SystemException {
108 if (isInheritLookAndFeel()) {
109 return getLayoutSet().getTheme();
110 }
111 else {
112 return ThemeLocalServiceUtil.getTheme(
113 getCompanyId(), getThemeId(), false);
114 }
115 }
116
117 @Override
118 public String getTypeSettings() {
119 if (_typeSettingsProperties == null) {
120 return super.getTypeSettings();
121 }
122 else {
123 return _typeSettingsProperties.toString();
124 }
125 }
126
127 @Override
128 public UnicodeProperties getTypeSettingsProperties() {
129 if (_typeSettingsProperties == null) {
130 _typeSettingsProperties = new UnicodeProperties(true);
131
132 _typeSettingsProperties.fastLoad(super.getTypeSettings());
133 }
134
135 return _typeSettingsProperties;
136 }
137
138 @Override
139 public ColorScheme getWapColorScheme()
140 throws PortalException, SystemException {
141
142 if (isInheritLookAndFeel()) {
143 return getLayoutSet().getWapColorScheme();
144 }
145 else {
146 return ThemeLocalServiceUtil.getColorScheme(
147 getCompanyId(), getWapTheme().getThemeId(),
148 getWapColorSchemeId(), true);
149 }
150 }
151
152 @Override
153 public Theme getWapTheme() throws PortalException, SystemException {
154 if (isInheritWapLookAndFeel()) {
155 return getLayoutSet().getWapTheme();
156 }
157 else {
158 return ThemeLocalServiceUtil.getTheme(
159 getCompanyId(), getWapThemeId(), true);
160 }
161 }
162
163 @Override
164 public boolean hasChildren() throws SystemException {
165 if (!getChildren().isEmpty()) {
166 return true;
167 }
168
169 return false;
170 }
171
172 @Override
173 public boolean hasDefaultAssetPublisherPortletId() {
174 UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();
175
176 String defaultAssetPublisherPortletId =
177 typeSettingsProperties.getProperty(
178 LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID);
179
180 if (Validator.isNotNull(defaultAssetPublisherPortletId)) {
181 return true;
182 }
183 else {
184 return false;
185 }
186 }
187
188 @Override
189 public boolean isInheritLookAndFeel() {
190 if (Validator.isNull(getThemeId()) ||
191 Validator.isNull(getColorSchemeId())) {
192
193 return true;
194 }
195 else {
196 return false;
197 }
198 }
199
200 @Override
201 public boolean isInheritWapLookAndFeel() {
202 if (Validator.isNull(getWapThemeId()) ||
203 Validator.isNull(getWapColorSchemeId())) {
204
205 return true;
206 }
207 else {
208 return false;
209 }
210 }
211
212 @Override
213 public void setTypeSettings(String typeSettings) {
214 _typeSettingsProperties = null;
215
216 super.setTypeSettings(typeSettings);
217 }
218
219 @Override
220 public void setTypeSettingsProperties(
221 UnicodeProperties typeSettingsProperties) {
222
223 _typeSettingsProperties = typeSettingsProperties;
224
225 super.setTypeSettings(_typeSettingsProperties.toString());
226 }
227
228 private UnicodeProperties _typeSettingsProperties;
229
230 }