001
014
015 package com.liferay.portlet.asset.model;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.portlet.LiferayPortletRequest;
020 import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
021 import com.liferay.portal.kernel.util.LocaleUtil;
022 import com.liferay.portal.kernel.util.WebKeys;
023 import com.liferay.portal.security.permission.PermissionChecker;
024 import com.liferay.portal.theme.ThemeDisplay;
025
026 import java.util.Locale;
027
028 import javax.portlet.PortletRequest;
029 import javax.portlet.PortletURL;
030
031
034 public abstract class BaseAssetRenderer implements AssetRenderer {
035
036 public String[] getAvailableLocales() {
037 return _EMPTY_ARRAY;
038 }
039
040 public String getDiscussionPath() {
041 return null;
042 }
043
044 public String getIconPath(PortletRequest portletRequest) {
045 ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
046 WebKeys.THEME_DISPLAY);
047
048 return getIconPath(themeDisplay);
049 }
050
051
054 public String getSummary() {
055 if (_calledGetSummary && _calledGetSummaryWithLocale) {
056 throw new UnsupportedOperationException(
057 "One of the getSummary methods must be implemented");
058 }
059
060 _calledGetSummary = true;
061
062 Locale locale = LocaleUtil.getDefault();
063
064 return getSummary(locale);
065 }
066
067 public String getSummary(Locale locale) {
068 if (_calledGetSummary && _calledGetSummaryWithLocale) {
069 throw new UnsupportedOperationException(
070 "One of the getSummary methods must be implemented");
071 }
072
073 _calledGetSummaryWithLocale = true;
074
075 return getSummary();
076 }
077
078
081 public String getTitle() {
082 if (_calledGetTitle && _calledGetTitleWithLocale) {
083 throw new UnsupportedOperationException(
084 "One of the getTitle methods must be implemented");
085 }
086
087 _calledGetTitle = true;
088
089 Locale locale = LocaleUtil.getDefault();
090
091 return getTitle(locale);
092 }
093
094 public String getTitle(Locale locale) {
095 if (_calledGetTitle && _calledGetTitleWithLocale) {
096 throw new UnsupportedOperationException(
097 "One of the getTitle methods must be implemented");
098 }
099
100 _calledGetTitleWithLocale = true;
101
102 return getTitle();
103 }
104
105 public PortletURL getURLEdit(
106 LiferayPortletRequest liferayPortletRequest,
107 LiferayPortletResponse liferayPortletResponse)
108 throws Exception {
109
110 return null;
111 }
112
113 public PortletURL getURLExport(
114 LiferayPortletRequest liferayPortletRequest,
115 LiferayPortletResponse liferayPortletResponse)
116 throws Exception {
117
118 return null;
119 }
120
121 public String getUrlTitle() {
122 return null;
123 }
124
125 public String getURLViewInContext(
126 LiferayPortletRequest liferayPortletRequest,
127 LiferayPortletResponse liferayPortletResponse,
128 String noSuchEntryRedirect)
129 throws Exception {
130
131 return null;
132 }
133
134 public String getViewInContextMessage() {
135 return "view-in-context";
136 }
137
138 @SuppressWarnings("unused")
139 public boolean hasEditPermission(PermissionChecker permissionChecker)
140 throws PortalException, SystemException {
141
142 return false;
143 }
144
145 @SuppressWarnings("unused")
146 public boolean hasViewPermission(PermissionChecker permissionChecker)
147 throws PortalException, SystemException {
148
149 return true;
150 }
151
152 public boolean isConvertible() {
153 return false;
154 }
155
156 public boolean isLocalizable() {
157 return false;
158 }
159
160 public boolean isPrintable() {
161 return false;
162 }
163
164 protected String getIconPath(ThemeDisplay themeDisplay) {
165 return themeDisplay.getPathThemeImages() + "/common/page.png";
166 }
167
168 private static final String[] _EMPTY_ARRAY = new String[0];
169
170 private boolean _calledGetSummary;
171 private boolean _calledGetSummaryWithLocale;
172 private boolean _calledGetTitle;
173 private boolean _calledGetTitleWithLocale;
174
175 }