001
014
015 package com.liferay.portlet.messageboards.action;
016
017 import com.liferay.portal.kernel.servlet.SessionErrors;
018 import com.liferay.portal.kernel.util.ParamUtil;
019 import com.liferay.portal.security.auth.PrincipalException;
020 import com.liferay.portal.struts.PortletAction;
021 import com.liferay.portlet.messageboards.service.MBThreadServiceUtil;
022
023 import javax.portlet.ActionRequest;
024 import javax.portlet.ActionResponse;
025 import javax.portlet.PortletConfig;
026
027 import org.apache.struts.action.ActionForm;
028 import org.apache.struts.action.ActionMapping;
029
030
033 public class DeleteThreadAction extends PortletAction {
034
035 public void processAction(
036 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
037 ActionRequest actionRequest, ActionResponse actionResponse)
038 throws Exception {
039
040 try {
041 deleteThread(actionRequest, actionResponse);
042
043 sendRedirect(actionRequest, actionResponse);
044 }
045 catch (Exception e) {
046 if (e instanceof PrincipalException) {
047 SessionErrors.add(actionRequest, e.getClass().getName());
048
049 setForward(actionRequest, "portlet.message_boards.error");
050 }
051 else {
052 throw e;
053 }
054 }
055 }
056
057 protected void deleteThread(
058 ActionRequest actionRequest, ActionResponse actionResponse)
059 throws Exception {
060
061 long threadId = ParamUtil.getLong(actionRequest, "threadId");
062
063 MBThreadServiceUtil.deleteThread(threadId);
064 }
065
066 }