1
22
23 package com.liferay.portlet.messageboards.action;
24
25 import com.liferay.portal.kernel.util.ParamUtil;
26 import com.liferay.portal.theme.ThemeDisplay;
27 import com.liferay.portal.util.PortalUtil;
28 import com.liferay.portal.util.WebKeys;
29 import com.liferay.portlet.messageboards.model.MBCategory;
30 import com.liferay.portlet.messageboards.model.MBMessage;
31 import com.liferay.portlet.messageboards.model.MBThread;
32 import com.liferay.portlet.messageboards.model.impl.MBCategoryImpl;
33 import com.liferay.portlet.messageboards.service.MBBanLocalServiceUtil;
34 import com.liferay.portlet.messageboards.service.MBCategoryServiceUtil;
35 import com.liferay.portlet.messageboards.service.MBMessageServiceUtil;
36 import com.liferay.portlet.messageboards.service.MBThreadLocalServiceUtil;
37
38 import javax.portlet.ActionRequest;
39 import javax.portlet.RenderRequest;
40
41 import javax.servlet.http.HttpServletRequest;
42
43
49 public class ActionUtil {
50
51 public static void getCategory(ActionRequest req) throws Exception {
52 HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(req);
53
54 getCategory(httpReq);
55 }
56
57 public static void getCategory(RenderRequest req) throws Exception {
58 HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(req);
59
60 getCategory(httpReq);
61 }
62
63 public static void getCategory(HttpServletRequest req) throws Exception {
64
65
68 ThemeDisplay themeDisplay = (ThemeDisplay)req.getAttribute(
69 WebKeys.THEME_DISPLAY);
70
71 MBBanLocalServiceUtil.checkBan(
72 themeDisplay.getPortletGroupId(), themeDisplay.getUserId());
73
74 long categoryId = ParamUtil.getLong(req, "categoryId");
75
76 MBCategory category = null;
77
78 if ((categoryId > 0) &&
79 (categoryId != MBCategoryImpl.DEFAULT_PARENT_CATEGORY_ID)) {
80
81 category = MBCategoryServiceUtil.getCategory(categoryId);
82 }
83
84 req.setAttribute(WebKeys.MESSAGE_BOARDS_CATEGORY, category);
85 }
86
87 public static void getMessage(ActionRequest req) throws Exception {
88 HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(req);
89
90 getMessage(httpReq);
91 }
92
93 public static void getMessage(RenderRequest req) throws Exception {
94 HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(req);
95
96 getMessage(httpReq);
97 }
98
99 public static void getMessage(HttpServletRequest req) throws Exception {
100 long messageId = ParamUtil.getLong(req, "messageId");
101
102 MBMessage message = null;
103
104 if (messageId > 0) {
105 message = MBMessageServiceUtil.getMessage(messageId);
106 }
107
108 req.setAttribute(WebKeys.MESSAGE_BOARDS_MESSAGE, message);
109 }
110
111 public static void getThreadMessage(RenderRequest req) throws Exception {
112 HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(req);
113
114 getThreadMessage(httpReq);
115 }
116
117 public static void getThreadMessage(ActionRequest req) throws Exception {
118 HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(req);
119
120 getThreadMessage(httpReq);
121 }
122
123 public static void getThreadMessage(HttpServletRequest req)
124 throws Exception {
125
126 long threadId = ParamUtil.getLong(req, "threadId");
127
128 MBMessage message = null;
129
130 if (threadId > 0) {
131 MBThread thread = MBThreadLocalServiceUtil.getThread(threadId);
132
133 message = MBMessageServiceUtil.getMessage(
134 thread.getRootMessageId());
135 }
136
137 req.setAttribute(WebKeys.MESSAGE_BOARDS_MESSAGE, message);
138 }
139
140 }