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.portal.model;
16  
17  import com.liferay.portal.kernel.events.Action;
18  import com.liferay.portal.kernel.events.ActionException;
19  import com.liferay.portal.kernel.util.ParamUtil;
20  import com.liferay.portal.kernel.util.StringPool;
21  import com.liferay.portal.kernel.util.UnicodeProperties;
22  import com.liferay.portal.kernel.util.Validator;
23  import com.liferay.portal.service.LayoutLocalServiceUtil;
24  import com.liferay.portlet.journal.NoSuchContentSearchException;
25  import com.liferay.portlet.journal.service.JournalContentSearchLocalServiceUtil;
26  
27  import javax.servlet.http.HttpServletRequest;
28  import javax.servlet.http.HttpServletResponse;
29  
30  /**
31   * <a href="LayoutTypeArticleConfigurationDeleteAction.java.html"><b><i>View
32   * Source</i></b></a>
33   *
34   * @author Raymond Augé
35   */
36  public class LayoutTypeArticleConfigurationDeleteAction extends Action {
37  
38      public void run(HttpServletRequest request, HttpServletResponse response)
39          throws ActionException {
40  
41          try {
42              long groupId = ParamUtil.getLong(request, "groupId");
43              boolean privateLayout = ParamUtil.getBoolean(
44                  request, "privateLayout");
45              long layoutId = ParamUtil.getLong(request, "layoutId");
46  
47              Layout layout = LayoutLocalServiceUtil.getLayout(
48                  groupId, privateLayout, layoutId);
49  
50              UnicodeProperties typeSettingsProperties =
51                  layout.getTypeSettingsProperties();
52  
53              String articleId = typeSettingsProperties.getProperty("article-id");
54  
55              if (Validator.isNull(articleId)) {
56                  return;
57              }
58  
59              try {
60                  JournalContentSearchLocalServiceUtil.deleteArticleContentSearch(
61                      layout.getGroupId(), layout.isPrivateLayout(),
62                      layout.getLayoutId(), StringPool.BLANK, articleId);
63              }
64              catch (NoSuchContentSearchException nscse) {
65              }
66          }
67          catch (Exception e) {
68              throw new ActionException(e);
69          }
70      }
71  
72  }