1
14
15 package com.liferay.portlet.messageboards.action;
16
17 import com.liferay.portal.kernel.servlet.SessionErrors;
18 import com.liferay.portal.kernel.util.ParamUtil;
19 import com.liferay.portal.security.auth.PrincipalException;
20 import com.liferay.portal.struts.PortletAction;
21 import com.liferay.portlet.messageboards.service.MBThreadServiceUtil;
22
23 import javax.portlet.ActionRequest;
24 import javax.portlet.ActionResponse;
25 import javax.portlet.PortletConfig;
26
27 import org.apache.struts.action.ActionForm;
28 import org.apache.struts.action.ActionMapping;
29
30
35 public class DeleteThreadAction extends PortletAction {
36
37 public void processAction(
38 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
39 ActionRequest actionRequest, ActionResponse actionResponse)
40 throws Exception {
41
42 try {
43 deleteThread(actionRequest, actionResponse);
44
45 sendRedirect(actionRequest, actionResponse);
46 }
47 catch (Exception e) {
48 if (e instanceof PrincipalException) {
49 SessionErrors.add(actionRequest, e.getClass().getName());
50
51 setForward(actionRequest, "portlet.message_boards.error");
52 }
53 else {
54 throw e;
55 }
56 }
57 }
58
59 protected void deleteThread(
60 ActionRequest actionRequest, ActionResponse actionResponse)
61 throws Exception {
62
63 long threadId = ParamUtil.getLong(actionRequest, "threadId");
64
65 MBThreadServiceUtil.deleteThread(threadId);
66 }
67
68 }