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 @Override
055 public String getClassName() {
056 return MBThread.class.getName();
057 }
058
059 @Override
060 public long getClassPK() {
061 return _thread.getPrimaryKey();
062 }
063
064 @Override
065 public String getIconPath(ThemeDisplay themeDisplay) {
066 return themeDisplay.getPathThemeImages() + "/common/conversation.png";
067 }
068
069 @Override
070 public String getPortletId() {
071 return PortletKeys.MESSAGE_BOARDS;
072 }
073
074 @Override
075 public String getSummary(Locale locale) {
076 return null;
077 }
078
079 @Override
080 public String getTitle(Locale locale) {
081 return HtmlUtil.stripHtml(_rootMessage.getSubject());
082 }
083
084 @Override
085 public String getType() {
086 return TYPE;
087 }
088
089 @Override
090 public String render(
091 RenderRequest renderRequest, RenderResponse renderResponse,
092 String template)
093 throws Exception {
094
095 MBMessageDisplay messageDisplay =
096 MBMessageServiceUtil.getMessageDisplay(
097 _rootMessage.getMessageId(), WorkflowConstants.STATUS_ANY,
098 MBThreadConstants.THREAD_VIEW_TREE, false);
099
100 renderRequest.setAttribute(
101 WebKeys.MESSAGE_BOARDS_MESSAGE, messageDisplay);
102
103 MBTreeWalker treeWalker = messageDisplay.getTreeWalker();
104
105 renderRequest.setAttribute(
106 WebKeys.MESSAGE_BOARDS_TREE_WALKER, treeWalker);
107 renderRequest.setAttribute(
108 WebKeys.MESSAGE_BOARDS_TREE_WALKER_CATEGORY,
109 messageDisplay.getCategory());
110 renderRequest.setAttribute(
111 WebKeys.MESSAGE_BOARDS_TREE_WALKER_CUR_MESSAGE,
112 treeWalker.getRoot());
113 renderRequest.setAttribute(
114 WebKeys.MESSAGE_BOARDS_TREE_WALKER_DEPTH, new Integer(0));
115 renderRequest.setAttribute(
116 WebKeys.MESSAGE_BOARDS_TREE_WALKER_LAST_NODE, Boolean.FALSE);
117 renderRequest.setAttribute(
118 WebKeys.MESSAGE_BOARDS_TREE_WALKER_SEL_MESSAGE, _rootMessage);
119 renderRequest.setAttribute(
120 WebKeys.MESSAGE_BOARDS_TREE_WALKER_THREAD,
121 messageDisplay.getThread());
122
123 return "/html/portlet/message_boards/view_thread_tree.jsp";
124 }
125
126 private MBMessage _rootMessage;
127 private MBThread _thread;
128
129 }