001
014
015 package com.liferay.portlet.messageboards.trash;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.trash.BaseTrashRenderer;
020 import com.liferay.portal.kernel.util.HtmlUtil;
021 import com.liferay.portal.kernel.workflow.WorkflowConstants;
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.messageboards.model.MBMessage;
026 import com.liferay.portlet.messageboards.model.MBMessageDisplay;
027 import com.liferay.portlet.messageboards.model.MBThread;
028 import com.liferay.portlet.messageboards.model.MBThreadConstants;
029 import com.liferay.portlet.messageboards.model.MBTreeWalker;
030 import com.liferay.portlet.messageboards.service.MBMessageLocalServiceUtil;
031 import com.liferay.portlet.messageboards.service.MBMessageServiceUtil;
032
033 import java.util.Locale;
034
035 import javax.portlet.RenderRequest;
036 import javax.portlet.RenderResponse;
037
038
041 public class MBThreadTrashRenderer extends BaseTrashRenderer {
042
043 public static final String TYPE = "message_thread";
044
045 public MBThreadTrashRenderer(MBThread thread)
046 throws PortalException, SystemException {
047
048 _thread = thread;
049
050 _rootMessage = MBMessageLocalServiceUtil.getMBMessage(
051 thread.getRootMessageId());
052 }
053
054 public String getClassName() {
055 return MBThread.class.getName();
056 }
057
058 public long getClassPK() {
059 return _thread.getPrimaryKey();
060 }
061
062 @Override
063 public String getIconPath(ThemeDisplay themeDisplay) {
064 return themeDisplay.getPathThemeImages() + "/common/conversation.png";
065 }
066
067 public String getPortletId() {
068 return PortletKeys.MESSAGE_BOARDS;
069 }
070
071 public String getSummary(Locale locale) {
072 return null;
073 }
074
075 public String getTitle(Locale locale) {
076 return HtmlUtil.stripHtml(_rootMessage.getSubject());
077 }
078
079 public String getType() {
080 return TYPE;
081 }
082
083 @Override
084 public String render(
085 RenderRequest renderRequest, RenderResponse renderResponse,
086 String template)
087 throws Exception {
088
089 MBMessageDisplay messageDisplay =
090 MBMessageServiceUtil.getMessageDisplay(
091 _rootMessage.getMessageId(), WorkflowConstants.STATUS_ANY,
092 MBThreadConstants.THREAD_VIEW_TREE, false);
093
094 renderRequest.setAttribute(
095 WebKeys.MESSAGE_BOARDS_MESSAGE, messageDisplay);
096
097 MBTreeWalker treeWalker = messageDisplay.getTreeWalker();
098
099 renderRequest.setAttribute(
100 WebKeys.MESSAGE_BOARDS_TREE_WALKER, treeWalker);
101 renderRequest.setAttribute(
102 WebKeys.MESSAGE_BOARDS_TREE_WALKER_CATEGORY,
103 messageDisplay.getCategory());
104 renderRequest.setAttribute(
105 WebKeys.MESSAGE_BOARDS_TREE_WALKER_CUR_MESSAGE,
106 treeWalker.getRoot());
107 renderRequest.setAttribute(
108 WebKeys.MESSAGE_BOARDS_TREE_WALKER_DEPTH, new Integer(0));
109 renderRequest.setAttribute(
110 WebKeys.MESSAGE_BOARDS_TREE_WALKER_LAST_NODE, Boolean.FALSE);
111 renderRequest.setAttribute(
112 WebKeys.MESSAGE_BOARDS_TREE_WALKER_SEL_MESSAGE, _rootMessage);
113 renderRequest.setAttribute(
114 WebKeys.MESSAGE_BOARDS_TREE_WALKER_THREAD,
115 messageDisplay.getThread());
116
117 return "/html/portlet/message_boards/view_thread_tree.jsp";
118 }
119
120 private MBMessage _rootMessage;
121 private MBThread _thread;
122
123 }