1
14
15 package com.liferay.portlet.calendar.asset;
16
17 import com.liferay.portal.kernel.exception.PortalException;
18 import com.liferay.portal.kernel.exception.SystemException;
19 import com.liferay.portal.kernel.portlet.LiferayPortletRequest;
20 import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
21 import com.liferay.portal.security.permission.ActionKeys;
22 import com.liferay.portal.theme.ThemeDisplay;
23 import com.liferay.portal.util.PortletKeys;
24 import com.liferay.portal.util.WebKeys;
25 import com.liferay.portlet.asset.model.AssetRenderer;
26 import com.liferay.portlet.asset.model.BaseAssetRendererFactory;
27 import com.liferay.portlet.calendar.model.CalEvent;
28 import com.liferay.portlet.calendar.service.CalEventLocalServiceUtil;
29 import com.liferay.portlet.calendar.service.permission.CalendarPermission;
30
31 import javax.portlet.PortletURL;
32
33
39 public class CalEventAssetRendererFactory extends BaseAssetRendererFactory {
40
41 public static final String CLASS_NAME = CalEvent.class.getName();
42
43 public static final String TYPE = "event";
44
45 public AssetRenderer getAssetRenderer(long classPK)
46 throws PortalException, SystemException {
47
48 CalEvent event = CalEventLocalServiceUtil.getEvent(classPK);
49
50 return new CalEventAssetRenderer(event);
51 }
52
53 public String getClassName() {
54 return CLASS_NAME;
55 }
56
57 public String getType() {
58 return TYPE;
59 }
60
61 public PortletURL getURLAdd(
62 LiferayPortletRequest liferayPortletRequest,
63 LiferayPortletResponse liferayPortletResponse) {
64
65 ThemeDisplay themeDisplay =
66 (ThemeDisplay)liferayPortletRequest.getAttribute(
67 WebKeys.THEME_DISPLAY);
68
69 PortletURL addAssetURL = null;
70
71 if (CalendarPermission.contains(
72 themeDisplay.getPermissionChecker(),
73 themeDisplay.getScopeGroupId(), ActionKeys.ADD_EVENT)) {
74
75 addAssetURL = liferayPortletResponse.createRenderURL(
76 PortletKeys.CALENDAR);
77
78 addAssetURL.setParameter("struts_action", "/calendar/edit_event");
79 }
80
81 return addAssetURL;
82 }
83
84 protected String getIconPath(ThemeDisplay themeDisplay) {
85 return themeDisplay.getPathThemeImages() + "/common/date.png";
86 }
87
88 }