001
014
015 package com.liferay.portlet.messageboards.asset;
016
017 import com.liferay.portal.kernel.portlet.LiferayPortletRequest;
018 import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
019 import com.liferay.portal.theme.ThemeDisplay;
020 import com.liferay.portal.util.PortletKeys;
021 import com.liferay.portal.util.WebKeys;
022 import com.liferay.portlet.PortletURLFactoryUtil;
023 import com.liferay.portlet.messageboards.model.MBMessage;
024
025 import javax.portlet.PortletRequest;
026 import javax.portlet.PortletURL;
027 import javax.portlet.RenderRequest;
028 import javax.portlet.RenderResponse;
029
030 import javax.servlet.http.HttpServletRequest;
031
032
036 public class MBDiscussionAssetRenderer extends MBMessageAssetRenderer {
037
038 public MBDiscussionAssetRenderer(MBMessage message) {
039 super(message);
040
041 _message = message;
042 }
043
044 @Override
045 public PortletURL getURLEdit(
046 LiferayPortletRequest liferayPortletRequest,
047 LiferayPortletResponse liferayPortletResponse)
048 throws Exception {
049
050 HttpServletRequest request =
051 liferayPortletRequest.getHttpServletRequest();
052
053 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
054 WebKeys.THEME_DISPLAY);
055
056 PortletURL editPortletURL = PortletURLFactoryUtil.create(
057 request, PortletKeys.MESSAGE_BOARDS,
058 getControlPanelPlid(themeDisplay), PortletRequest.RENDER_PHASE);
059
060 editPortletURL.setParameter(
061 "struts_action", "/message_boards/edit_discussion");
062 editPortletURL.setParameter(
063 "messageId", String.valueOf(_message.getMessageId()));
064
065 return editPortletURL;
066 }
067
068 @Override
069 public String getURLViewInContext(
070 LiferayPortletRequest liferayPortletRequest,
071 LiferayPortletResponse liferayPortletResponse,
072 String noSuchEntryRedirect) {
073
074 return null;
075 }
076
077 @Override
078 public String render(
079 RenderRequest renderRequest, RenderResponse renderResponse,
080 String template)
081 throws Exception {
082
083 if (template.equals(TEMPLATE_ABSTRACT) ||
084 template.equals(TEMPLATE_FULL_CONTENT)) {
085
086 renderRequest.setAttribute(
087 WebKeys.MESSAGE_BOARDS_MESSAGE, _message);
088
089 return
090 "/html/portlet/message_boards/asset/discussion_" + template +
091 ".jsp";
092 }
093 else {
094 return null;
095 }
096 }
097
098 private MBMessage _message;
099
100 }