1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.webform.action;
16  
17  import com.liferay.portal.kernel.util.StringPool;
18  import com.liferay.portal.kernel.util.Validator;
19  import com.liferay.portal.struts.PortletAction;
20  import com.liferay.portlet.PortletPreferencesFactoryUtil;
21  import com.liferay.portlet.expando.service.ExpandoTableLocalServiceUtil;
22  import com.liferay.portlet.webform.util.WebFormUtil;
23  
24  import javax.portlet.ActionRequest;
25  import javax.portlet.ActionResponse;
26  import javax.portlet.PortletConfig;
27  import javax.portlet.PortletPreferences;
28  
29  import org.apache.struts.action.ActionForm;
30  import org.apache.struts.action.ActionMapping;
31  
32  /**
33   * <a href="DeleteDataAction.java.html"><b><i>View Source</i></b></a>
34   *
35   * @author Jorge Ferrer
36   */
37  public class DeleteDataAction extends PortletAction {
38  
39      public void processAction(
40              ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
41              ActionRequest actionRequest, ActionResponse actionResponse)
42          throws Exception {
43  
44          PortletPreferences preferences =
45              PortletPreferencesFactoryUtil.getPortletSetup(actionRequest);
46  
47          String databaseTableName = preferences.getValue(
48              "databaseTableName", StringPool.BLANK);
49  
50          if (Validator.isNotNull(databaseTableName)) {
51              ExpandoTableLocalServiceUtil.deleteTable(
52                  WebFormUtil.class.getName(), databaseTableName);
53          }
54  
55          sendRedirect(actionRequest, actionResponse);
56      }
57  
58  }