001
014
015 package com.liferay.portlet.calendar.asset;
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.security.permission.ActionKeys;
022 import com.liferay.portal.theme.ThemeDisplay;
023 import com.liferay.portal.util.PortletKeys;
024 import com.liferay.portal.util.WebKeys;
025 import com.liferay.portlet.asset.model.AssetRenderer;
026 import com.liferay.portlet.asset.model.BaseAssetRendererFactory;
027 import com.liferay.portlet.calendar.model.CalEvent;
028 import com.liferay.portlet.calendar.service.CalEventLocalServiceUtil;
029 import com.liferay.portlet.calendar.service.permission.CalendarPermission;
030
031 import javax.portlet.PortletURL;
032
033
036 public class CalEventAssetRendererFactory extends BaseAssetRendererFactory {
037
038 public static final String CLASS_NAME = CalEvent.class.getName();
039
040 public static final String TYPE = "event";
041
042 public AssetRenderer getAssetRenderer(long classPK, int type)
043 throws PortalException, SystemException {
044
045 CalEvent event = CalEventLocalServiceUtil.getEvent(classPK);
046
047 return new CalEventAssetRenderer(event);
048 }
049
050 public String getClassName() {
051 return CLASS_NAME;
052 }
053
054 public String getType() {
055 return TYPE;
056 }
057
058 public PortletURL getURLAdd(
059 LiferayPortletRequest liferayPortletRequest,
060 LiferayPortletResponse liferayPortletResponse) {
061
062 ThemeDisplay themeDisplay =
063 (ThemeDisplay)liferayPortletRequest.getAttribute(
064 WebKeys.THEME_DISPLAY);
065
066 PortletURL addAssetURL = null;
067
068 if (CalendarPermission.contains(
069 themeDisplay.getPermissionChecker(),
070 themeDisplay.getScopeGroupId(), ActionKeys.ADD_EVENT)) {
071
072 addAssetURL = liferayPortletResponse.createRenderURL(
073 PortletKeys.CALENDAR);
074
075 addAssetURL.setParameter("struts_action", "/calendar/edit_event");
076 }
077
078 return addAssetURL;
079 }
080
081 protected String getIconPath(ThemeDisplay themeDisplay) {
082 return themeDisplay.getPathThemeImages() + "/common/date.png";
083 }
084
085 }