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.impl.MBCategoryImpl;
32 import com.liferay.portlet.messageboards.service.MBBanLocalServiceUtil;
33 import com.liferay.portlet.messageboards.service.MBCategoryServiceUtil;
34 import com.liferay.portlet.messageboards.service.MBMessageServiceUtil;
35
36 import javax.portlet.ActionRequest;
37 import javax.portlet.RenderRequest;
38
39 import javax.servlet.http.HttpServletRequest;
40
41
47 public class ActionUtil {
48
49 public static void getCategory(ActionRequest req) throws Exception {
50 HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(req);
51
52 getCategory(httpReq);
53 }
54
55 public static void getCategory(RenderRequest req) throws Exception {
56 HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(req);
57
58 getCategory(httpReq);
59 }
60
61 public static void getCategory(HttpServletRequest req) throws Exception {
62
63
66 ThemeDisplay themeDisplay = (ThemeDisplay)req.getAttribute(
67 WebKeys.THEME_DISPLAY);
68
69 MBBanLocalServiceUtil.checkBan(
70 themeDisplay.getPortletGroupId(), themeDisplay.getUserId());
71
72 long categoryId = ParamUtil.getLong(req, "categoryId");
73
74 MBCategory category = null;
75
76 if ((categoryId > 0) &&
77 (categoryId != MBCategoryImpl.DEFAULT_PARENT_CATEGORY_ID)) {
78
79 category = MBCategoryServiceUtil.getCategory(categoryId);
80 }
81
82 req.setAttribute(WebKeys.MESSAGE_BOARDS_CATEGORY, category);
83 }
84
85 public static void getMessage(ActionRequest req) throws Exception {
86 HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(req);
87
88 getMessage(httpReq);
89 }
90
91 public static void getMessage(RenderRequest req) throws Exception {
92 HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(req);
93
94 getMessage(httpReq);
95 }
96
97 public static void getMessage(HttpServletRequest req) throws Exception {
98 long messageId = ParamUtil.getLong(req, "messageId");
99
100 MBMessage message = null;
101
102 if (messageId > 0) {
103 message = MBMessageServiceUtil.getMessage(messageId);
104 }
105
106 req.setAttribute(WebKeys.MESSAGE_BOARDS_MESSAGE, message);
107 }
108
109 }