1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
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  /**
31   * <a href="DeleteThreadAction.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Deepak Gothe
34   */
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  }